• 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: No longer use NSLog() in Xcode 4?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No longer use NSLog() in Xcode 4?


  • Subject: Re: No longer use NSLog() in Xcode 4?
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 15 Sep 2011 13:34:37 -0700

On 2011 Sep 15, at 12:16, Scott Ribe wrote:

> Well, if you used __LINE__ in your NSLog statements instead of reading the cursor position, then perhaps you wouldn't have to read anything in your script.

Yes, except the really nice thing about %%%{PBXSelectionStart}%%% is that it gives me a unique identifier with 99.99% probability.  For example, say that I wanted to hone in on where an exception was being raised.  I'd pepper the suspect code, even if spread across different files, with NSLogs including %%%{PBXSelectionStart}%%%.  Each one takes only one keystroke.  Build and run.  Console will print out something like this:

145656
145856
12674
12874
13476
*** Exception Blah Blah.
13487

Bang.  Just do a ⇧⌘F, copy that 13476 to the search field, and in seconds the problem is staring me in the face.

__FILE__ would be useful if it didn't print out the whole damned full path.

> Then for removing them, perhaps you could use regex search & replace based on your signature comment.

My script deletes the entirety of any line that has the signature comment.  Since C allows more than one statement on a line, I can also put in other temporary statements such as

   thatString = @"Try this string!" ; NSLog(…) ;

and my remove-debugging script blows away all such lines with one keystroke.

My signature comment is: /*DB?Line*/.  A regex like this should work:

   [^\n]/\*DB\?Line\*/[^\n]+\n

Unfortunately, I remember learning once that Xcode's regex does not parse newlines, and just confirmed that still seems to be the case.  So the \n on the end breaks it, and without it, I'm left with a blank line.

But thank you, Scott.  I'll keep trying.

* * *

Code Snippets would start to fill the bill if there were some environment variables available.


_______________________________________________

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

  • Follow-Ups:
    • Re: No longer use NSLog() in Xcode 4?
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Timeout back to login screen
  • Next by Date: Re: No longer use NSLog() in Xcode 4?
  • Previous by thread: Re: Timeout back to login screen
  • Next by thread: Re: No longer use NSLog() in Xcode 4?
  • Index(es):
    • Date
    • Thread