控制流 / 其他运算符

@interface WeatherService : NSObject
@property (nonatomicreadonly)
    NSMutableDictionary *map;
@end

@implementation WeatherService {
    NSMutableDictionary *_map;
}

//lazy: the getter creates the value
//on first access only
- (NSMutableDictionary *)map {
    if (_map == nil) {
        //2. Creating WeatherMap
        _map = [NSMutableDictionary
            dictionary];
    }
    return _map;
}
@end

WeatherService *service =
    [WeatherService new];
//1. Before accessing the map
NSMutableDictionary *map = service.map;
//created here, once