CopyPastor

Detecting plagiarism made easy.

Score: 0.8278863250171654; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-12-24
by jawadAli

Original Post

Original - Posted on 2015-04-21
by Aaron Brager



            
Present in both answers; Present only in the new answer; Present only in the old answer;

`lazy var` is not thread safe. You can use `dispatch_once`, a constant (`let`), or the nested struct pattern (typically used for singletons) for thread safety. You could also employ your own locking using `NSRecursiveLock` but that's probably not as efficient as `dispatch_once`.
It seems not all `lazy` variables are guaranteed to be initialized once in multi-threaded environment. You need to explicitly program it so or use static property.
> Although lazy loading may help developers to reduce memory footprint, > to avoid loading too many data into the memory, or even to work around > some sort of initialization or setup problems (such as setup views > when you need to access self when the instance of self is not > initialized). Nevertheless, applying lazy loading is not always > toll-free: sometimes you will have to go extra miles to avoid > side-effects. Lastly, don’t be afraid of lazy variables. it’s still a > wonderful thing that can help you for the purpose of its existence. > Cheers!
`lazy var` is not thread safe. You can use `dispatch_once`, a constant (`let`), or the nested struct pattern (typically used for singletons) for thread safety. You could also employ your own locking using `NSRecursiveLock` but that's probably not as efficient as `dispatch_once`.

        
Present in both answers; Present only in the new answer; Present only in the old answer;