Re: Serious problem with XCode 2.2 treating unsigned long differently ?!
Re: Serious problem with XCode 2.2 treating unsigned long differently ?!
- Subject: Re: Serious problem with XCode 2.2 treating unsigned long differently ?!
- From: Eyal Redler <email@hidden>
- Date: Mon, 14 Nov 2005 09:11:19 +0200
I'm not following that. Are you saying that running the sample
code below should print out an exception? It doesn't for me, with
either gcc 3.3 or 4.0.1, whether I define TestTypeLong as an
unsigned int or as an unsigned long.
I have three version of the app:
A - a version compiled using ProjectBuilder/XCode 1.5/etc. This
version does @encode(unsigned long) correctly giving you an 'L'
B - a version compiled using XCode 2.1. This version does @encode
(unsigned long) incorrectly giving you an 'I'
C - a version compiled using XCode 2.2. This version does @encode
(unsigned long) correctly again, giving you an 'L'
Now, there are two cases:
1. If I try to open an archive created with version A in version B -
> it works
2. If I try to open an archive created with version B in version C -
> I get an exception
These are the facts. My theory was that we can conclude that:
In case '1' it is expecting an 'I' but getting an 'L' but not raising
an exception.
In case '2' it is expecting an 'L' but getting an 'I' and raising an
exception.
The sample code tried to test the theory by encoding the variable
using unsigned long and decode using unsigned int and vice versa but
the code fails both ways which means my theory is not correct and the
question remains, how can version B read version A archives.
As I hinted at above, this is missing a typedef for TestTypeLong.
Do you have a complete example here that we can just drop into a
file and compile? That'd be a big help.
Sorry about that, you will get an exception if you different types in
initWithCoder and encodeWithCoder but this is not really surprising
since it should give you an exception, the mystery is why I didn't
get an exception with the Xcode 2.1 compiled version reading earlier
archives.
@interface ERTestEncoding : NSObject{
unsigned int instanceVar;
}
@end
@implementation ERTestEncoding
- (id)initWithCoder:(NSCoder*)coder{
self= [super init];
if (self)
[coder decodeValueOfObjCType:@encode(unsigned int) at:&instanceVar];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder{
[coder encodeValueOfObjCType:@encode(unsigned long)
at:&instanceVar];
}
@end
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
ERTestEncoding* object=[[ERTestEncoding alloc] init];
[NSUnarchiver unarchiveObjectWithData:[NSArchiver
archivedDataWithRootObject:object]];
[object release];
[pool release];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden