I have seen in some source code (by other developers) something like this:
#import "SomeClass+SomeOtherClass.h"
What is the + for? What does this mean?
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.
Let’s say you want to add functionality to an existing class (exp:
NSString). You can do that by creating a subclass or you can use a category. And it is common to name the file where the category is defined using the pattern :MyClass+MyCategory.h.For example, we can add a method
reverseStringto the classNSStringin a category:Have a look at this documentation for more information about categories.
Then you can use that category in another class: