Home > DeveloperSection > Forums > How does a Category Works in iOS?
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    January-05-2016 6:51 AM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 1456  View(s)
Rate this:
I have created an application using Objective-C code. In my code I have a need for extending a standard class of a iOS framework with an instance variable plus accessors.
I learn learn Apple's developer documentation about 'Category' and its sounds pretty confusing to me.

Can anyone tell me the basic functionality of Category.
Thankyou.


Tarun Kumar

Total Post:213

Points:1635
Posted on    January-05-2016 10:23 PM

Category is a unique feature in iOS because with this help we can add our custom methods inside our own classes or predefined classes means(framework classes).
for example- I have created a custom method and I want to use this method anywhere in our Application. now at this condition we can add this method into any framework class using Category.

Now, if you need to add instance variables to a class, a category would not do the job, categories only add methods not data.
So, to add instance variables you must subclass.


Don't want to miss updates? Please click the below button!

Follow MindStick