Problem when archiving data: [_NSViewGState encodeWithCoder:] unrecognized selector
Problem when archiving data: [_NSViewGState encodeWithCoder:] unrecognized selector
- Subject: Problem when archiving data: [_NSViewGState encodeWithCoder:] unrecognized selector
- From: JArod Wen <email@hidden>
- Date: Fri, 25 Jul 2008 18:29:02 -0400
Hi Jedis,
Problem showed when I was trying to archive the following data
object(in debug model: po items):
<CFArray 0x77db6c0 [0xa01dc174]>{type = mutable-small, count = 3,
values = (
0 : <CFDictionary 0x5a95a80 [0xa01dc174]>{type = immutable, count =
5, capacity = 6, pairs = (
2 : <CFString 0x77e2700 [0xa01dc174]>{contents = "w (D)"} =
<distanceObj: 0x774a1c0>
3 : <CFString 0x77e3e80 [0xa01dc174]>{contents = "r (S)"} =
<shapeObj: 0x7749fc0>
4 : <CFString 0x3bca8 [0xa01dc174]>{contents = "time"} = <CFNumber
0x77dbe90 [0xa01dc174]>{value = +0.0, type = kCFNumberFloat64Type}
6 : <CFString 0x77e2350 [0xa01dc174]>{contents = "e (A)"} = <CFNumber
0x47e9f0 [0xa01dc174]>{value = +0.76225443599111997184, type =
kCFNumberFloat64Type}
7 : <CFString 0x77e26e0 [0xa01dc174]>{contents = "q (P)"} = NSPoint:
{316, 179}
)}
1 : <CFDictionary 0x5a94ab0 [0xa01dc174]>{type = immutable, count =
5, capacity = 6, pairs = (
2 : <CFString 0x77e2700 [0xa01dc174]>{contents = "w (D)"} =
<distanceObj: 0x774a1c0>
3 : <CFString 0x77e3e80 [0xa01dc174]>{contents = "r (S)"} =
<shapeObj: 0x7749fc0>
4 : <CFString 0x3bca8 [0xa01dc174]>{contents = "time"} = <CFNumber
0x5aa7bf0 [0xa01dc174]>{value = +1.00000000000000000000, type =
kCFNumberFloat64Type}
6 : <CFString 0x77e2350 [0xa01dc174]>{contents = "e (A)"} = <CFNumber
0x77f1010 [0xa01dc174]>{value = +0.60900385903412623811, type =
kCFNumberFloat64Type}
7 : <CFString 0x77e26e0 [0xa01dc174]>{contents = "q (P)"} = NSPoint:
{370, 195}
)}
2 : <CFDictionary 0x4ac9b0 [0xa01dc174]>{type = immutable, count = 5,
capacity = 6, pairs = (
2 : <CFString 0x77e2700 [0xa01dc174]>{contents = "w (D)"} =
<distanceObj: 0x774a1c0>
3 : <CFString 0x77e3e80 [0xa01dc174]>{contents = "r (S)"} =
<shapeObj: 0x7749fc0>
4 : <CFString 0x3bca8 [0xa01dc174]>{contents = "time"} = <CFNumber
0x475a60 [0xa01dc174]>{value = +2.00000000000000000000, type =
kCFNumberFloat64Type}
6 : <CFString 0x77e2350 [0xa01dc174]>{contents = "e (A)"} = <CFNumber
0x77f1010 [0xa01dc174]>{value = +0.60900385903412623811, type =
kCFNumberFloat64Type}
7 : <CFString 0x77e26e0 [0xa01dc174]>{contents = "q (P)"} = NSPoint:
{370, 195}
)}
)}
These data are from a table, which contains four columns:
time(NSNumber), w(D)(distanceObj), r(S)(shapeObj), e(A)(NSNumber), and
q(P)(NSPoint). distanceObj and shapeObj are defined as following:
@interface distanceObj: NSObject <NSCoding>{
NSPoint origin;
NSPoint terminus;
NSNumber * magnitude;
}
@property (readwrite, assign) NSPoint origin;
@property (readwrite, assign) NSPoint terminus;
@property (readwrite, assign) NSNumber* magnitude;
@end
@interface shapeObj: NSObject <NSCoding>{
NSNumber * count;
NSPoint * points;;
}
@property (readwrite, assign) NSNumber * count;
@property (readwrite, assign) NSPoint * points;
@end
The methods for encoding and decoding in distanceObj and shapeObj have
been implemented:
- (id)initWithCoder:(NSCoder *)coder{
[super init];
[coder decodeValueOfObjCType:@encode(NSPoint) at:&origin];
[coder decodeValueOfObjCType:@encode(NSPoint) at:&terminus];
[coder decodeValueOfObjCType:@encode(NSNumber *) at:&magnitude];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder{
[coder encodeValueOfObjCType:@encode(NSPoint) at:&origin];
[coder encodeValueOfObjCType:@encode(NSPoint) at:&terminus];
[coder encodeValueOfObjCType:@encode(NSNumber *) at:&magnitude];
}
- (id)initWithCoder:(NSCoder *)coder{
[super init];
[self setCount:[coder decodeObject]];
[coder decodeValueOfObjCType:@encode(NSPoint *) at:&points];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder{
[coder encodeObject:count];
[coder decodeValueOfObjCType:@encode(NSPoint *) at:&points];
}
When the application was running on
[NSArchiver archiveRootObject:[[[appController tableController]
tableSource] items] toFile:[sheet filename]];
There would be two errors and then failed to write into file:
2008-07-25 18:01:27.198 Roboplasm[2353:813] *** -[_NSViewGState
encodeWithCoder:]: unrecognized selector sent to instance 0x7752480
2008-07-25 18:01:27.821 Roboplasm[2353:813] *** -[_NSViewGState
encodeWithCoder:]: unrecognized selector sent to instance 0x7752480
Since I didn't find any object in the data to be written has the type
of NSViewGState, I am really confused about this error. Anyone can
give me any suggestions?
Thanks in advance!
---------------
JArod Wen
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden