Wouldn't this mean that using nil as an indicator would be not good? I mean, if you're trying to release myObject's image and indicate that there is no image, setting to nil instead serves as a reset/reload, which probably isn't the intent. How about this, instead?
That way, if, for some reason, instead of loading the image, if the nib specifies an image, and it's later nilled out, the loadImage isn't inappropriately called if someone checks or is otherwise bound.
Also: is there any command that can set a bit/bool and return its previous value, atomically? That way, you don't need locks on loadedMyImage, and it'd be threadsafe.
by Blain — Jun 18
MyClass* myObject = [[MyClass alloc] init]; NSImage* currentImage = [myObject myImage]; [myObject setMyImage:nil]; currentImage = [myObject myImage];
Wouldn't this mean that using nil as an indicator would be not good? I mean, if you're trying to release myObject's image and indicate that there is no image, setting to nil instead serves as a reset/reload, which probably isn't the intent. How about this, instead?
That way, if, for some reason, instead of loading the image, if the nib specifies an image, and it's later nilled out, the loadImage isn't inappropriately called if someone checks or is otherwise bound.
Also: is there any command that can set a bit/bool and return its previous value, atomically? That way, you don't need locks on loadedMyImage, and it'd be threadsafe.