- (NSImage*)myImage { if ( myImage == nil ) { [self willChangeValueForKey:@"myImage"]; myImage = [[self fetchImageFromDisk] copy]; [self didChangeValueForKey:@"myImage"]; } return myImage; }
Copyright © Scott Stevenson 2004-2015
by Justin — Jun 16
- (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.