Class extensions @interface Class () are a lot more powerful and can inject variables into the class. Categories @interface Class (Category) can’t.
What other differences are there, and when should one use a category over a class extension?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The main difference is that with an extension, the compiler will expect you to implement the methods within your main
@implementation, whereas with a category you have a separate@implementationblock. So you should pretty much only use an extension at the top of your main.mfile (the only place you should care about ivars, incidentally) — it’s meant to be just that, an extension.