Re: String Comparison and return values
Re: String Comparison and return values
- Subject: Re: String Comparison and return values
- From: Thomas Davie <email@hidden>
- Date: Tue, 26 May 2009 10:04:15 +0200
Op 26 May 2009, om 09:56 heeft John Ku het volgende geschreven:
Oh so the very first return value from a Dictionary is not actually a
string?
NSString *itemA = [DictionaryA valueForKey:@"FirstProcessIdentifier"];
I've check the apple document, valueForKey returns an ID... so it
return an
object? how do I proceed?
If i cast it as NSString it gives me an error.
Simple - sort your type error out! The dictionary contains at least
one number. This means that either you're creating it wrong, or
you're trying to get values out of it wrong...
In the latter case you might want to try something like
id item = [dictionaryA valueForKey:@"FirstProcessIdentifier"];
if ([item isKindOfClass:[NSString class]])
{
// do stuff
}
else if ([item isKindOfClass:[NSNumber class]])
{
// do other stuff
}
...
Bob
_______________________________________________
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