• 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: How to write a dictionary into an output file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to write a dictionary into an output file


  • Subject: Re: How to write a dictionary into an output file
  • From: "Michael Ash" <email@hidden>
  • Date: Mon, 5 Jun 2006 19:08:50 -0400

On 6/5/06, Julio Bianco <email@hidden> wrote:
Hi,
I'm trying to write son dictionary information in a file, and I
realize that I can do it using the method

- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag

and I use it like this:

+(TCLogger *) instance {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSDictionary *LogFile1 = [[NSDictionary alloc] initWithObjectsAndKeys:
                @"one", [NSNumber numberWithInt: 1],
                nil];

        if ([LogFile1 writeToFile: @"/Users/jbianco/pueba.log" atomically:
YES])

The documentation on this method states:

"This method recursively validates that all the contained objects are
property list objects...."

If you follow the link to the "Property List Programming Guide" just
below that quote and read "About Property Lists", you will find the
following:

"Although dictionary keys in NSDictionary and CFDictionary are defined
to be an object of any type, for property lists they must be string
objects."

By creating a dictionary that uses an NSNumber as a key, you are
creating a dictionary that is not a valid property list, and therefore
can't be saved using that method. Either use only string keys, or look
into using NSKeyedArchiver instead.

Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >How to write a dictionary into an output file (From: Julio Bianco <email@hidden>)

  • Prev by Date: Re: nsslider subclass not responding to mouseUp:
  • Next by Date: what is ABMetaDataController and why is it raising an exception?
  • Previous by thread: Re: How to write a dictionary into an output file
  • Next by thread: Re: no rule to process file
  • Index(es):
    • Date
    • Thread