• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSBitmapImageRep subclass problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSBitmapImageRep subclass problem (SOLVED)
      • From: Alan Hart <email@hidden>
References: 
 >NSBitmapImageRep subclass problem (From: Alan Hart <email@hidden>)
 >Re: NSBitmapImageRep subclass problem (From: Nicko van Someren <email@hidden>)

  • Prev by Date: advice needed for NSArrayController's selection bindings
  • Next by Date: Setting origins for NSMatrix cells
  • Previous by thread: Re: NSBitmapImageRep subclass problem
  • Next by thread: Re: NSBitmapImageRep subclass problem (SOLVED)
  • Index(es):
    • Date
    • Thread