Skip navigation.
 
mlRe: Adding Categories to NSMutableData
FROM : Ken Thomases
DATE : Thu May 29 20:27:07 2008

On May 29, 2008, at 12:59 PM, Robert Kukuchka wrote:

>     I'm trying to add a simple category to NSMutableData, but when I 
> try to call my method I'm getting "*** -[NSConcreteData 
> remainderDataWithParseByte:]: unrecognized selector sent to instance 
> 0x816400". I've added categories to NSString and NSArray before, 
> which have similar abstract interfaces to concrete classes. Is there 
> some trick I'm missing?


Have you verified that the object really isKindOfClass:[NSMutableData 
class] ?

Using class-dump on the Foundation framework shows me that 
NSConcreteData subclasses NSData, while NSConcreteMutableData is a 
subclass of NSMutableData.

Given the nature of class clusters and the private concrete classes 
within them, I suppose it's possible that you did everything right 
(asked for an NSMutableData) but were given an NSConcreteData instead, 
and that it does the right thing in almost all cases.  I'd still 
consider it a bug in the framework if a category on NSMutableData 
didn't work on it, if that's the case.

Cheers,
Ken

Related mailsAuthorDate
mlAdding Categories to NSMutableData Robert Kukuchka May 29, 19:59
mlRe: Adding Categories to NSMutableData Kenny Leung May 29, 20:24
mlRe: Adding Categories to NSMutableData Ken Thomases May 29, 20:27
mlRe: Adding Categories to NSMutableData Robert Kukuchka May 29, 20:46