Swift is the same as the OC Lazy loading mechanism, but this aspect of the domestic data is relatively small, today, the search engine for Bing after the discovery of Bing to find English \ The latest information is stronger than Baidu.
We typically do this in OC to initialize lazy loading:
1: @property (nonatomic, strong) Nsmutablearray *players;
2:
3: -(Nsmutablearray *) Players {
4: if (!_players) {
5: _players = [[Nsmutablearray alloc] init];
6: }
7: return _players;
8: }
And with Baidu search "Swift lazy load lazy" but there is no decent information, are scripted.
We can actually write this:
1: lazy var players:nsmutablearray = {
2: var temporaryplayers = Nsmutablearray ()
3: temporaryplayers.addobject ("Mike Buss")
4: return temporaryplayers
5: } ()
Solve the problem perfectly! Thanks bing!
Lazy initialization with Swift
http://www.tuicool.com/articles/I3mY7v
Http://stackoverflow.com/questions/24068829/lazy-loading-properties-in-swift
Lazy Loading (lazy initialization) implementation in Swift