Questions tagged [nslog]

Logs an error message to the Apple System Log facility.

The message consists of a timestamp and the process ID prefixed to the string you pass in. You compose this string with a format string and one or more arguments to be inserted into the string. The format specification allowed by this function is that which is understood by NSString’s formatting capabilities.

Displaying log messages in the system console while running your application is one of the oldest debugging mechanisms available. Using logging, you can generate a transcript describing the operations being performed by your application that you can review long after your application has finished running. Also, while your application is running, you can observe log messages being generated and written to the console as the events in your app they describe are taking place. As a developer, you are in complete control of the text and information displayed in the console by NSLog. Logging can reveal even the toughest to find problems in an app.

Here is an example of what a call to NSLog looks like:

NSString *message = @"test message";

NSLog( @"Here is a test message: '%@'", message );

Console:

Here is a test message: 'test message'

Reference:

Basic debugging with the NSLog function and the DEBUG preprocessor macro

667 questions
3
votes
1 answer

clear logs generated by NSlog from consol by code

I want to clear logs from consol by coding like we are using clrscr() in c language I am working on a navigation based application this application has too much logs generated by NSLog. When i feel that the code is working fine till now, i want to…
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
3
votes
3 answers

Treat using NSLog as a build error

I want to treat any NSLog in my code as an error. The line should be a compile time error in Xcode. Just like how usage of release in an ARC enabled project is treated as an error.
Vinoth Kumar
  • 156
  • 8
3
votes
1 answer

How to acces an objects restoration id (why is it null?)

I have uiButtons in an xib. I have set restoration ids for all of them. I need to print a list of these restoration ids. to do this i call the following code in viewDidload: -(void)loadViewFromNIB:(NSString *)nibName owner:(id)owner { NSArray…
fozbstuios
  • 373
  • 4
  • 8
  • 17
3
votes
2 answers

Disable NSLog for a specific class

I know how you can disable all NSLog messages from answers like this one and this one. It's yet unclear to me what should I define in my .pch file to conditionally disable NSLog in a separate class. Any ideas?
Sergey Grischyov
  • 11,995
  • 20
  • 81
  • 120
3
votes
2 answers

Display the tableview row selected in NSLog

How can I display the cell selected from my tableview in NSLog?
Tom John
  • 99
  • 1
  • 7
3
votes
3 answers

what does the NSLog array count code shown do?

NSLog(@"%d",[annotations count]); The above code is used with an NSMutableArray named 'annotations'. My question is... what does this code do exactly? I know NSLog outputs text, and its saying annotations count.. so I am thinking that it outputs…
Simagen
  • 409
  • 2
  • 8
  • 18
3
votes
2 answers

How to delete all NSLog's & comments from my Xcode application?

Is there anyway to delete the NSLog lines from the app by any trick/tool? I usually use NSLog's in each and every method to understand the flow of control and to know about the values of the app's variables. I also use lots of comment lines to…
Confused
  • 3,846
  • 7
  • 45
  • 72
3
votes
2 answers

NSLog ignored on devices

I am trying to redirect all NSLog output to be able to see all my logs in a UITextView inside the app (for debug purposes, and maybe later to log everything using TestFlight). I can't use the well-known DLog because I want to catch logs from…
3
votes
2 answers

How do I check NSLog output?

I would like to check if NSLog() for some string has actually printed out something. Is there a way I can check the length of the output of an NSLog statement or create a string from it? It's for a proof of concept, not a practical solution, so…
John Lane
  • 1,112
  • 1
  • 14
  • 32
3
votes
2 answers

Why does an NSView's frame method return the wrong results?

I occasionally want to change an NSView's dimensions programmaticaly. To do this, it is helpful to get the dimensions of various views, adjust them relative to each other, and then use setFrame: to reposition. The problem is that the frame method…
Dennis
  • 1,215
  • 1
  • 12
  • 15
3
votes
2 answers

Xcode, Why are some NSLog entries omitted from the console?

I'm just beginning to learn IOS development. Everytime I run this program, the console does not always display my NSLogs. #import int main(int argc, const char * argv[]) { @autoreleasepool { NSMutableArray…
Waynelee3d
  • 33
  • 5
2
votes
1 answer

ObjC - Problems with using an NSLog replacement?

Being relatively new to programming--think Programming in Objective-C by Kochan, Chapter 15--I'm wondering if there's a reason why it's a bad idea--especially for a new programmer?--to use an NSLog replacement such as the following: #define…
baptzmoffire
  • 589
  • 2
  • 4
  • 20
2
votes
1 answer

how print this NSDictionary?

NSLog give me this when i print some NSDictionary object. I see, that in this NSDictionary are few NSDictionary objects. i must to send this to UITextView, but this must be one list without {ExifAux}, {Exif}, {IPTC}, {TIFF}. how can i do…
Tomasz Szulc
  • 4,217
  • 4
  • 43
  • 79
2
votes
2 answers

How to determine the structure of an iOS (id) object?

When I call a certain function from my iOS app, it returns an id data type. I can't see into this function so I don't know what it's doing or what the return type really is. If I print it to console using NSLog("@"...) I get a string similar to…
Jonathan
  • 1,498
  • 2
  • 20
  • 41
2
votes
2 answers

NSLog doesn't work in my blessed HelperTool

To create custom packets and use libpcap, I've created a helper tool that run as root thanks to SMJobBless. In my helper tool, NSLog doesn't send any logs to console.app. I have to use syslog which send me logs in the console, but I've got problems…
Tom
  • 613
  • 6
  • 14