There is a class (reference type), which is a property of a structure (type value), at the moment when I initialize a structure, I pass the class to the initializer, what link does the field bind to the class reference, weak or strong? If strong, then at what point in time will the property release the object, and if it was the only link, it will release the memory

struct SomeStruct { var classRef: MyClass } 

Closed due to the fact that the issue is too general for the participants Max Mikheyenko , aleksandr barakin , user194374, αλεχολυτ , Streletz 3 Sep '16 at 12:19 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    For storing constants you can think of many ways. The most common and simple (maybe even the most correct):

    1 Analog to #define - global get-variables. Example:

     var someDisabledColor: UIcolor { return UIColor.blackColor() } 

    2 Structures. The most convenient, well structured. Example:

     struct Config { struct Colors { static let someBackgroundColor = UIColor.redColor() static let someDisabledColor = UIColor.blackColor() } struct Values { static let someValue = 10 } } someView.backgroundColor = Config.Colors.someBackgroundColor 

    PS Singleton usually used for other purposes. Well, if you look for memory from problem areas, it’s definitely not here.