Q: I have allocated an instance of NXBitmapImageRep and am reusing the instance in my application with repeated calls to
-initData:pixelsWide:pixelHigh:bitsPerSample:samplesPerPixel:
hasAlpha:isPlanar:colorSpace:bytesPerRow:bitsPerPixel:
each time passing a new chunk of raw image data. However my application is crashing. Is my use of -initData legal?
Q: Once I have allocated an object in the AppKit can I then reinitialize it repeatedly?
A: The init methods should never be called twice on the same alloc'd instance. Some classes allow you to reuse an instance by resetting key values using a setFoo: method. However this is not possible with the NXBitmapImageRep class. In this case, the overhead of the alloc is very small; the required implementation is to free the previous instance and allocate a new one on the fly each time you need to perform an initData.
QA663
Valid for 2.0, 3.0