Can lazy loading be considered an example of RAII?
- by codemonkey
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?