Can lazy loading be considered an example of RAII?
        Posted  
        
            by 
                codemonkey
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by codemonkey
        
        
        
        Published on 2012-09-27T15:30:48Z
        Indexed on 
            2012/09/27
            15:37 UTC
        
        
        Read the original article
        Hit count: 355
        
I have been catching up on my c++ lately, after a couple years of exclusive Objective-C on iOS, and the topic that comes up most on 'new style' c++ is RAII
To make sure I understand RAII concept correctly, would you consider Objective-C lazy loading property accessors a type of RAII? For example, check the following access method
- (NSArray *)items {
    if(_items==nil) {
        _items=[[NSArray alloc] initWithCapacity:10];
    }
    return _items
}
Would this be considered an example of RAII? If not, can you please explain where I'm mistaken?
© Stack Overflow or respective owner