0

Do I need to delete all NSLog commands and every comment lines ( /* [...] */ )before releasing my application and putting it on Appstore?

  • 1
    You should read a good book on C. You seem to be lacking fundamental knowledge about the language and its nature. Comments are gone during the compilation phase - if you don't understand this, you should not be writing iOS apps yet, instead, you should be learning the basics of C. –  Aug 14 '13 at 17:20

2 Answers2

3

You can open NSLog only in DEBUG building.

#ifdef DEBUG
        #define NSLog(fmt, ...)     NSLog((@"%@ [Line: %d] %s " fmt),[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__)
#else
        #define NSLog(fmt, ...)
#endif

put it to the global header file or Prefix.pch

Elf Sundae
  • 1,575
  • 16
  • 23
2

NSLog: They should be removed. As pointed out by @sosborn, NSLog is slow and can cause and even hide subtle timing and concurrency bugs. For basic debugging NSLog is fantastic, but after you're done debugging you really should remove them. @Elf Sundae's answer is fantastic and shows you how to make it so NSLogs will be displayed ONLY when debugging and automagically hid when you release your application.

Comments: No

Matt S.
  • 13,305
  • 15
  • 73
  • 129
  • 3
    NSLog can be slow and it can cause/hide subtle timing/concurrency bigs. – sosborn Aug 14 '13 at 15:46
  • Yes, absolutely! I can't tell you how many times I've had that happen to me. But for a simple application (which is what I assume op has made) it doesn't matter. – Matt S. Aug 14 '13 at 15:48
  • 2
    It's a big assumption that the OP made a "simple" app. Also, people other than OP will be using these answers. – sosborn Aug 14 '13 at 16:03
  • Very true. Editing my answer to reflect that. – Matt S. Aug 14 '13 at 16:04