Should I put all my methods in one category (I mean for the same kind of object) or should I split them up in many files? (Something like NSStringAdditions vs. NSString+this and NSString+that)
Share
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.
That very much depends.
If they are closely related to each other, put them in the same category. If they solve quite different tasks, then splitting them is appropriate.
Also, reusing in different projects my be a point to consider.
Always treat categories with care, though. Although it is possible to extend existing classes, and in some cases it is justified use, don’t abuse them. They come at a cost (performance, flexibility, maintenance). So if you have to decide to split your category, this is most of the time a sign for too much complexity here, and a subclass or other helper class is the better choice.