Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RossOliver

macrumors regular
Original poster
Nov 6, 2006
157
0
Hey,

I'm trying to make a few of my classes NSCoding compliant and I am having trouble encoding arrays with:

Code:
- (void)encodeArrayOfObjCType:(const char *)itemType count:(NSUInteger)count at:(const void *)address

I have both an array of NSString objects and an array of a custom objects. When I try and encode the NSString array using:

Code:
[encoder encodeArrayOfObjCType:@encode( NSString ) count:[myArray count] at:&myArray];

I get the error message:

CoreAnimation: ignoring exception: *** -[NSKeyedArchiver encodeArrayOfObjCType:count:at:]: unsupported type "{NSString=#}" for array encoding

I don't understand why NSString is not supported since it complies with the NSCoding protocol? Is there a list of supported types somewhere?

Any help would be greatly appreciated,

-Ross
 
Hi,

I believe encodeArrayOfObjCType:count:at: encodes a *C* array of Objective-C objects. To encode an NSArray, you can simply use encodeObject:.

Is there a list of supported types somewhere?
Not that I'm aware of, but I'm pretty sure any object that conforms to the NSCoding protocol can be encoded with encodeObject:, so you can look up each class in the documentation to see if they conform to this protocol or not.
 
Hi,

I believe encodeArrayOfObjCType:count:at: encodes a *C* array of Objective-C objects. To encode an NSArray, you can simply use encodeObject:.

Not that I'm aware of, but I'm pretty sure any object that conforms to the NSCoding protocol can be encoded with encodeObject:, so you can look up each class in the documentation to see if they conform to this protocol or not.


Ah, trying to make it harder for myself :eek:

Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.