Re: NSBitmapImageRep subclass problem
Re: NSBitmapImageRep subclass problem
- Subject: Re: NSBitmapImageRep subclass problem
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 7 Apr 2006 19:46:59 -0700
On Apr 7, 2006, at 12:06 PM, Nicko van Someren wrote:
On 7 Apr 2006, at 19:03, Alan Hart wrote:
However, I'd really prefer to do it using a PCXImageRep class,
defined and registered as a subclass of NSBitMapImageRep, since it
seems that's the way the Cocoa image architecture ought to work.
Then it would be available to read a .pcx file anywhere in my app,
and it would be more reusable elsewhere.
So I have:
...
- (BOOL) canInitWithData {
return YES;
}
Shouldn't that be a class method not an instance method?
That's one of the two mistakes here. +canInitWithData: takes a
parameter: an NSData object, which the method will examine to see
whether it can decode its contents. From the docs:
canInitWithData:
Returns a Boolean value indicating whether the receiver can
initialize itself from the specified data.
+ (BOOL)canInitWithData:(NSData *)data
Parameters
data
The image data.
Return Value
YES if the receiver understands the format of the specified data
and can use it to initialize itself; otherwise, NO.
Discussion
This method should be overridden by subclasses. Note that this
method does not need to do a comprehensive check of the image data;
it should return NO only if it knows it cannot initialize itself
from the data.
See Also
+ canInitWithPasteboard:
-jcr
John C. Randolph <email@hidden> (408) 914-0013
Roaming Cocoa Engineer,
Available for your projects at great Expense and Inconvenience.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden