Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between C# partial classes and Objective C categories?

Tags:

c#

objective-c

I am new to Objective C. having spent couple of months in iOS, I am struggling to understand usage of Objective C categories.

Are they same as C# partial classes and used to divide huge classes in to methods pertaining to a piece of requirement.

OR there is more to it than just this much ?

like image 897
Amogh Talpallikar Avatar asked Jan 30 '12 07:01

Amogh Talpallikar


1 Answers

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

The Apple documentation is pretty comprehensive about categories, so I suggest you to read it to fully understand the benefits.

Note: One advantage of categories over extension methods, is that you can add both instance and static methods to a class.

like image 75
Laurent Etiemble Avatar answered Oct 15 '22 19:10

Laurent Etiemble