NSMutableDictionary won't accept my NSString as Value (NEWBIE)
NSMutableDictionary won't accept my NSString as Value (NEWBIE)
- Subject: NSMutableDictionary won't accept my NSString as Value (NEWBIE)
- From: "Sebastian Pape" <email@hidden>
- Date: Thu, 23 Oct 2008 13:34:56 +0200
Hi,
This might be pretty easy for most of you. I've been trying to find
out how to solve that for the last one and a half hours and it just
doesn't work.
Basically this part of the application scans data from a buffer,
taking the first element found as "a Value" and the second element
found as "a Key" for a NSMutableDictionary.
But my NSMutableDictionary won't accept my NSString, because it
requires setValue:(id)value and I just have my NSString.
XCode gives me a warning about that and GDB sends me a "***
-[NSCFDictionary setValue:ForKey:]: unrecognized selector sent to
instance 0x1dd090".
I hope you can tell me what the problem is.
Thankyou
Sebastian.
____________________________________________
int i;
NSCharacterSet *dividerCharSet = [NSCharacterSet
characterSetWithCharactersInString:@":\r\n"];
NSCharacterSet *allCharSet = [NSCharacterSet
characterSetWithCharactersInString:@":\r\n "];
NSScanner*scanner = [NSScanner scannerWithString:buffer];
NSString *curValue;
NSMutableDictionary *messageDictionary;
messageDictionary = [[NSMutableDictionary alloc] initWithCapacity:30];
i=0;
while ( ![scanner isAtEnd] ) {
NSString *currentData;
[scanner scanUpToCharactersFromSet:dividerCharSet intoString:¤tData];
switch (i) {
case 0:
curValue = [[NSString alloc] initWithString:currentData];
[curValue retain];
i=1;
case 1:
[messageDictionary setValue:curValue ForKey:currentData]; //Here's
my problem!
[curValue release];
i=0;
}
break;
[scanner scanCharactersFromSet:allCharSet intoString:nil];
}
_______________________________________________
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