Login
Remember
Register
Ask a Question
What are some limitations and problems you can face with categories?
+2
votes
asked
Jan 19, 2022
in
C Plus Plus
by
DavidAnderson
What are some limitations and problems you can face with categories?
objective-c-interview-question-answer
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jan 19, 2022
by
DavidAnderson
Advantages
:
You can extend any class, even those, for which you do not have the source. Look, for example, into the UI extensions added by Apple to the NSString class for rendering, getting the metrics, etc.
Since you have access to all instance variables, categories provide you with a nice way to structure your code across compilation units using logical grouping instead of the “it must all be in one phyiscal place” approach taken, for example, by Java.
Disadvantages
:
You cannot safely override methods already defined by the class itself or another category.
...