• 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
Newbie warning: watch your NSLog data types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie warning: watch your NSLog data types


  • Subject: Newbie warning: watch your NSLog data types
  • From: Scott Ellsworth <email@hidden>
  • Date: Tue, 9 Aug 2005 11:30:45 -0700

Hi, all.

My code said

NSLog(@"\tExamining World: %@ - %@ - %@, WTN %f TM %f %@", [neighborWorld valueForKey:@"name"],[neighborWorld valueForKeyPath:@"sector.name"], [neighborWorld valueForKey:@"hex"], [neighborWorld tradeRating], tradeModForNeighbor, @"end");

The log said:

2005-08-09 11:20:49.426 Astrogator[14065] Examining World: Caliban - Core - 2218, WTN 0.000000 TM -0.000000 (null)

The code should have said:

NSLog(@"\tExamining World: %@ - %@ - %@, WTN %f TM %f %@", [neighborWorld valueForKey:@"name"],[neighborWorld valueForKeyPath:@"sector.name"], [neighborWorld valueForKey:@"hex"], [[neighborWorld tradeRating] floatValue], tradeModForNeighbor, @"end");

The log would then have said:

2005-08-09 11:27:36.330 Astrogator[14161] Examining World: Caliban - Core - 2218, WTN 0.000000 TM 10.800000 end

Obvious in retrospect: I had sent an NSNumber to something expecting a float.

It would be very nice if there were an NSLog debug mode that did (limited) type checking on arguments. I am still trying to figure out how to write that - any 16 bits is a valid int16, which is not easy to debug.

Scott

_______________________________________________
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


  • Follow-Ups:
    • Re: Newbie warning: watch your NSLog data types
      • From: Guy English <email@hidden>
  • Prev by Date: RE: Subclassing NSTextView under Tiger
  • Next by Date: NSData writeToFile:atomically not working right??
  • Previous by thread: Re: Core Data SQL store looses data that XML store does not
  • Next by thread: Re: Newbie warning: watch your NSLog data types
  • Index(es):
    • Date
    • Thread