• 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: Use of NSLog() for debugging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of NSLog() for debugging


  • Subject: Re: Use of NSLog() for debugging
  • From: "David P. Henderson" <email@hidden>
  • Date: Mon, 23 Jul 2001 16:00:20 -0400

On Monday, July 23, 2001, at 01:24 , Glen Simmons wrote:

Clark, what you haven't stumbled across, is that you can type "po myObject" in the console to find out the contents of these objects. The reason you haven't stumbled across this is because it isn't documented anywhere. Apparently, it's folklore that has to be handed down.

Actually, it is documented, in the gdb documents not the Project Builder documents. Look in the Developer Tools section of the Developer Help Center.

<rant>
What I don't understand is, if "po myObject" is what I'm gonna do the majority of the time, why isn't this part of the GUI? A disclosure triangle that only shows an isa variable is about as useful as an extra butt-cheek. No offense to the Next vets / command line gurus, but I don't like typing "po myObject". I like the debugger in CodeWarrior, Visual Studio, insert-a-modern-IDE-here. The debugger is my number one complaint about PB.
</rant>

Also po allows is far more useful than just po myOjbect; you can also perform objc methods on objects with both p and po, po [myObject someMethod]. Note this is only useful if the object method has a return value; if the return value is a primitive type, use p [object method].

On Monday, July 23, 2001, at 01:05 , Clark S. Cox III wrote:

Using NSLog() for debugging does not preclude the use of gdb. Often, there is no way to view the more complex types used in Cocoa. For example, I often insert NSLog() statements just before gdb breakpoints so that I can see the value(s) held in an NSString, NSNumber, NSArray, etc.

Rather than relying solely NSLog to provide this info, implement the - (NSString *)description method for each of your subclasses. If you do this, your object instances used in both NSLog's and from the debugger's print object command will return information more useful than <ClassName : address in memory>.

Dave
--
Chaos Assembly Werks
"The Trend over the last 20 years or so has been to design computer languages that enforce a state of paranoia. You're expected to program every module as if it were in a state of siege  In Perl culture, by contrast, you're expected to stay out of someone's home because you weren't invited in, not because there are bars on the windows."
from Programming Perl


  • Prev by Date: Re: C question about structs
  • Next by Date: Re: menu enabling/disabling in Java
  • Previous by thread: Re: Use of NSLog() for debugging
  • Next by thread: Re: Use of NSLog() for debugging
  • Index(es):
    • Date
    • Thread