Theocacao
Leopard
Design Element
Comment on "Lazy Loading of KVO Observed Properties"
by Justin — Jun 16
Why not use will/didChangeValueForKey?
- (NSImage*)myImage { if ( myImage == nil ) { [self willChangeValueForKey:@"myImage"]; myImage = [[self fetchImageFromDisk] copy]; [self didChangeValueForKey:@"myImage"]; } return myImage; }

Any code that acts on the image can be put into a third method used by the setter and getter.
Back to "Lazy Loading of KVO Observed Properties"
Design Element

Copyright © Scott Stevenson 2004-2015