Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS how can I package reusable code in a reusable UI widget? Like a heavily modified text widget?

Tags:

ios

iphone

ipad

iOS how can I package reusable code in a reusable UI widget? Like a heavily modified text widget?

I built a UITextView that has a lot of custom functionality specific to my application (hits webserver for some special macro features, has special autocomplete dictionary, etc...)

I want to reuse this special text entry in multiple screens on my iOS application. How can I neatly package this code up so it can easily be used as simply as a UITextView can be reused?

like image 333
MikeN Avatar asked Oct 24 '22 17:10

MikeN


2 Answers

you can create a class that will have UITextView as a super class and this class will also be the place for implementing your functions to support the custom functionality and further your class will be used directly instead UITextView for availing of the custom functionality .

like image 62
Jhaliya - Praveen Sharma Avatar answered Oct 27 '22 19:10

Jhaliya - Praveen Sharma


You put the @interface block in a .h file and the @implementation block in a .m file. Then in any file you want to use it in, #import the .h file at the top (using double-quotes, not angle-brackets).

like image 37
Anomie Avatar answered Oct 27 '22 19:10

Anomie