1. Check the information: Extension is often called an anonymous Category (for example: in the string class extension extension, the added attributes str1 and show method are private,
can only be used in the String class Accessible.
Excuse me: I have a question: What does it mean that the added attributes can only be accessed in the string class?
I wrote the NSString test.h extension and added @property. NSString *name attribute.
In other places, I can access: NSString *str1 = @"hello ";
str1.name. Is this considered access?
2. The extension only has one .h file. . If I add a method. In which file is this method implemented?
I would like to ask, what are the uses of [str1 copy], [mutStr2 mutCopy]? I ask a lot of questions during interviews, but they don’t seem to be used much in practice.
4. Lazy loading of iOS design patterns. I saw such an introduction. Design patterns include proxy pattern, MVC, singleton, and observation patterns. Is lazy loading also a design pattern? ? ? ? ! ! !
To add attributes to category, you need to implement its getter/setter methods
扩展只有一个.h文件。如果我加上了一个方法。这个方法实现在哪个 文件中?
The implementation is of course an .m file
heathWang talked about the first three, I will try to answer the last one. Granted, iOS is a bit confusing in this regard. As you said, lazy loading, observers, singletons, and proxies are design patterns. MVC and MVVM are called framework patterns. AFNetwork and Foundation are called frameworks.