@Blain: The other notable hint is that the convention seems to be that immutable objects retain instead of copy, but mutable objects copy to an immutable version
Some people may do that, but the "proper" convention is to always copy value objects -- strings, numbers, etc.
With NSImage, you also need to consider how the object is originally created. You can use either -initByReferencingFile: or -initWithContentsOfFile:. Quoth the documentation for the referencing version:
"This method initializes the image object lazily. It does not actually open the specified file or create any image representations from its data until an application attempts to draw the image or request information about it."
In terms of the bitmapData property, you're right. That's as low as it goes, and with good reason. You can actually walk that memory buffer and change the bitmap data, pixel by pixel.
The other possible exception is that -bitmapData forces the copy
by Scott Stevenson — Sep 29
Some people may do that, but the "proper" convention is to always copy value objects -- strings, numbers, etc.
With NSImage, you also need to consider how the object is originally created. You can use either -initByReferencingFile: or -initWithContentsOfFile:. Quoth the documentation for the referencing version:
"This method initializes the image object lazily. It does not actually open the specified file or create any image representations from its data until an application attempts to draw the image or request information about it."
In terms of the bitmapData property, you're right. That's as low as it goes, and with good reason. You can actually walk that memory buffer and change the bitmap data, pixel by pixel.
The other possible exception is that -bitmapData forces the copy
Possible. I don't know.