My application project contains several helper classes that serve all kinds (e.g. time / date / calculation, access to db, ..). The initiation of these classes is terminated because they contain some properties that must be populated from the database or must be recounted each time a new instance is created. To avoid performance problems I tend to initiate each of these classes in the application deletion and pass them from viewController to viewController.
This has worked for me for a while, but now I find that the more complex the application gets the more problems that I encounter. Mainly problems related to the confusion of classes in a circular reference. I would like to know how I can solve this correctly, I thought about turning each auxiliary class into a singleton, and instead use a singleton instead of passing an instance of the class. But since some helper classes are dependent on each other, I will have singlets called other singletones, I can't seem to figure out if this will lead to other problems at the end. Any advice on this?
, unit test . ; - ( , ), , , .
, , " " , , () :
- , , . , - . , , , . . , NSManagedObjectContext, NSManagedObject.
NSManagedObjectContext
NSManagedObject
. , , . . , , , . , , . , , , .
, . , , . , , , , , .
factory ? , -, appDelegate.
singleton.-, ...
And I'm sure the class instance is unique. I use it for single point access to a resource
Edit: It seems I'm wrong!what about flexible implementation?
static Singleton *sharedSingleton = nil; + (Singleton*)sharedManager { if (sharedSingleton == nil) { sharedSingleton = [[super alloc] init]; } return sharedSingleton; }
Source: https://habr.com/ru/post/1773039/More articles:Why is (3) .constructor valid when the "constructor" in (3) is invalid? - javascriptWhy does the ASP.NET error page return 404 as soon as the request appears using aspxerrorpath? - asp.netCreate a Gmap link from an address - google-mapsWPF, multi-linking CSV with checkbox list and best MVVM methods - wpfVMware Fusion 3.1 - Slow Windows Phone Emulator - windows-phone-7How to find the index of an item in a python list? - pythonHow to see XFA forms in i-Pad? - ipadVowel Counting Sequence - python"ambiguous symbol error" when creating a C ++ / Tcl program using the boost library - c ++How do you update the FX_schema.xml file in IIS 7? - xmlAll Articles