IPhone: static method versus sharedManager in Objective-C

I have a bunch of functions that return the commonly used UIView in my application, for example.

+ (UIView *) getLikeRow:(CGRect) frame ofType:(LikeType) type

So far I have used static methods for this, but recently I also noticed a concept sharedManager. Now I am wondering if I prefer to use sharedManager for this.

What are the differences and advantages / disadvantages of using static methods or instance methods of SingleMan? sharedManager?

+3
source share
1 answer

You use the singleton / shared-managed template when it is important that only one instance of the class is available at any time.

, , UIApplication. , . NSFileManager .

- singleton/shared-managed.

, . - , . , , :

UIView *theView=[MyViewUtilityClass getLikeRow:aRect ofType:aType];

, MyViewUtilityClass . , . , .pch, .

, singleton, , . , , -- C . .

, , . , , UIView , .

+7

Source: https://habr.com/ru/post/1743831/


All Articles