Difference between partial C # classes and Objective-C categories?

I am new to Objective C. After spending a couple of months on iOS, I am struggling to understand the use of Objective C. categories.

Are they the same as partial C # classes and are used to split huge classes into methods related to part of the requirement.

OR is it more than simple?

+8
c # objective-c
source share
2 answers
Categories

Objective-C is a way to add methods to existing classes. They can be compared with .NET extension methods.

Apple's documentation describes the categories in some detail, so I suggest you read it to fully understand the benefits.

Note One of the advantages of categories over extension methods is that you can add both instances and static methods to the class.

+6
source share

They are usually used more as extension methods than private classes.

With a category in Objective-C, you can add methods to the class that any user in your program can use implicitly, as if they were embedded in part of the class.

You can definitely use them as Partial Classes to separate implementations in multiple files, but I'm not sure I have ever seen it used in practice.

+4
source share

All Articles