• 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: NSLog and [NSDictionary description], bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLog and [NSDictionary description], bug?


  • Subject: Re: NSLog and [NSDictionary description], bug?
  • From: Nicko van Someren <email@hidden>
  • Date: Tue, 6 Apr 2004 12:21:39 +0100

On 6 Apr 2004, at 11:49, Stiphane Sudre wrote:

I'm using the following line of code for debugging purpose:

NSLog([myDictionary description]);

where myDictionary is a NSDictionary.

With some dictionaries, it crashes.

The most likely explanation is that something in the description of the dictionary is being interpreted as a formatting instruction that requires an argument of some sort.

The strange part is that:

- when I do a po in gdb (i.e. the similar kind of process AFAIK), it works.
- when I do NSLog(@"%@",myDictionary); it works too (there is no %@ in the dictionary objects).

Neither of the above will ever try to parse or interpret the dictionary description, they will just dump it.

Is this a known bug or limitation in NSLog?

The prototype for NSLog says:
void NSLog(NSString *format, ...)
What you are passing in your original call, while correct from the point of view of types, is not a format string, it's just a string. The correct and safe way to do what you want to do is NSLog(@"%@",myDictionary), which also takes less typing!

Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSLog and [NSDictionary description], bug?
      • From: Allan Odgaard <email@hidden>
References: 
 >NSLog and [NSDictionary description], bug? (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Re: NSLog and [NSDictionary description], bug?
  • Next by Date: Re: NSLog and [NSDictionary description], bug?
  • Previous by thread: Re: NSLog and [NSDictionary description], bug?
  • Next by thread: Re: NSLog and [NSDictionary description], bug?
  • Index(es):
    • Date
    • Thread