Re: isKindofClass with NSData and NSKeyUnarchiver
Re: isKindofClass with NSData and NSKeyUnarchiver
- Subject: Re: isKindofClass with NSData and NSKeyUnarchiver
- From: Alexander Spohr <email@hidden>
- Date: Thu, 27 May 2010 11:29:14 +0200
Am 27.05.2010 um 11:21 schrieb Philip Vallone:
>
> Hello,
>
> I am passing different types of data to NSData (NSString, NSArray, UIImage). I am trying to find out what kind of data t is so I know how to handle the NSData when I receive it. The below code is an example of how I am trying to do this but its always returning null. What am I doing wrong?
>
> NSString *somedata = [[NSString alloc] initWithString:@"Some string"];
> NSData * set = [NSKeyedArchiver archivedDataWithRootObject:[somedata dataUsingEncoding:NSASCIIStringEncoding]];
> NSData * unset = [NSKeyedUnarchiver unarchiveObjectWithData:set];
Unset is not a pointer to NSData, it is an id. Did you read the docs?
> NSLog(@"Class Type %@", [unset isKindOfClass:[NSKeyedUnarchiver class]]);
You ask if unset’s class is NSKeyedUnarchiver. That returns a BOOL (and always NO) but you tell NSLog to receive a pointer to an object. So you see a (null).
Try asking unset for its class...
atze
_______________________________________________
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