HOW DOES A CATEGORY WORKS IN IOS?

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 1623  View(s)
Ratings:
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.
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: How does a Category Works in iOS?

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!