• 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
Re: odd problem with NSMutableDictionary and initWithContentsOfFile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: odd problem with NSMutableDictionary and initWithContentsOfFile


  • Subject: Re: odd problem with NSMutableDictionary and initWithContentsOfFile
  • From: Michael Vannorsdel <email@hidden>
  • Date: Thu, 29 May 2008 02:46:39 -0600

You can't init an object more than once (well not an intended use). You do:

SimParamnames = [NSMutableDictionary dictionary];

and later:

[SimParamnames initWithContentsOfFile: aFile];

which are both initializing the object. The second init is either being ignored or perhaps corrupting the object. If you want a mutable dictionary of a file's contents you'll have to make a new one with [NSMutableDictionary dictionaryWithContentsOfFile:filePath].


[SimParamnames removeAllObjects] ; [SimParamnames initWithContentsOfFile: aFile];

might work better as:

[SimParamnames release]; //throw away the old dictionary
SimParamnames = [[NSMutableDictionary alloc] initWithContentsOfFile:aFile]; //make a new one from aFile


On May 28, 2008, at 1:58 AM, Leslie Smith wrote:

in a later method
	NSArray *filesToOpen = [oPanel filenames];
      int i, count1 = [filesToOpen count];
      for (i=0; i<count1; i++) {
          		NSString *aFile = [filesToOpen objectAtIndex:i];
			printf("%s\n", [aFile UTF8String]) ;
			[SimParamnames removeAllObjects] ;
          		[SimParamnames initWithContentsOfFile: aFile];
			NSLog(@"SimParamnames contains %d values", [SimParamnames count]) ;
			xxx = [NSMutableDictionary dictionaryWithContentsOfFile: aFile];
			NSLog(@"SimParamnames contains %d values", [SimParamnames count]) ;
			NSLog(@"xxx contains %d values", [xxx count]) ;
			result = 100 ;
      }

_______________________________________________

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


References: 
 >odd problem with NSMutableDictionary and initWithContentsOfFile (From: Leslie Smith <email@hidden>)

  • Prev by Date: Re: odd problem with NSMutableDictionary and initWithContentsOfFile
  • Next by Date: Re: Package Builder Questions
  • Previous by thread: Re: odd problem with NSMutableDictionary and initWithContentsOfFile
  • Next by thread: re: odd problem with NSMutableDictionary and initWithContentsOfFile
  • Index(es):
    • Date
    • Thread