• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSMutableDictionary won't accept my NSString as Value (NEWBIE)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:&currentData];

	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

  • Follow-Ups:
    • Re: NSMutableDictionary won't accept my NSString as Value (NEWBIE)
      • From: "Jonathan del Strother" <email@hidden>
  • Prev by Date: Re: Using Core Animation to animate view properties?
  • Next by Date: Re: NSMutableDictionary won't accept my NSString as Value (NEWBIE)
  • Previous by thread: CocoaHeads chapter Bonn (Germany) Kickoff TODAY
  • Next by thread: Re: NSMutableDictionary won't accept my NSString as Value (NEWBIE)
  • Index(es):
    • Date
    • Thread