nslog

Logging to a file on the iPhone

What would be the best way to write log statements to a file or database in an iPhone application? Ideally, NSLog() output could be redirected to a file using freopen(), but I've seen several reports that it doesn't work. Does anyone have this going already or have any ideas how this might best be done? Thanks! ...

Is it true that one should not use NSLog() on production code?

I was told this a few times in this very site, but I wanted to make sure this is really the case. I was expecting to be able to sprinkle NSLog function calls throughout my code, and that Xcode/gcc would automatically strip those calls out when building my Release/Distribution builds. Should I avoid using this? If so, what alternatives ...

Is there a way to capture the ouput of NSLog on an iPhone when not connected to a debugger?

I'm logging a bunch of data with NSLog(). Is there a way to capture the log data when my iPhone is not connected to my development machine and running under a debugger? For example, can I redirect it to a file and then read the log file back through Xcode at a later point in time? I need to do this in order to test my app when the W...

Why is my NSInteger changing from 12345 to -1758050543 when I pass it as an argument in an Obj-C method call?

Here's the code in AlertTableView: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSInteger index = 12345; NSLog(@"AlertTableView: selecting row at index %d", index); [self.caller didSelectRowAtIndex:index withContext:self.context]; } In self.caller: - (void)didSelectRowAtIndex:(NS...

What are some unique uses of NSLog you have used?

Do you have any unique or special uses of NSLog you use for debugging? ...

NSLog tips and tricks

Hi, I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently. I'd like to know if there are any tips and tricks to using NSLog which you guys have picked up. For example, is there a way to easily NSLog the current method's name / line number? is there a way to "disable" all NSLo...

How to get rid of the date and time that appears before every NSLog statement in the console

Hi, I use NSLog in my application. And I'd like to get rid of the annoying beginning of each string: "2009-07-01 21:11:06.508 MyApp[1191:207]". Is there a way to do so? Probably another logging function? Thanks. ...

OCUnit, NSLog, and XCode 3.1

I'd been using OCUnit (the default installation that comes with XCode) in XCode 3.0. I've been happy being able to run my tests and see the results in the Build Results window, as well as any NSLog() messages I output. However, with XCode 3.1 the tests run fine, but I suddenly lose my NSLog() output. Anybody know where it went? ...

NSLog not printing to terminal

Ok, so I've been using NSLog in objective-C for awhile now to debug and I know it's supposed to print to the terminal whatever I put in the parentheses. For some reason, it just stopped printing to the terminal and I'm not sure how to fix this error. I was wondering what other people would suggest doing to fix this problem. I've only inc...

What is the Objective-C equivalent for "toString()", for use with NSLog?

Is there a method that I can override in my custom classes so that when NSLog(@"%@", myObject) is called, it will print the fields (or whatever I deem important) of my object? I guess I'm looking for the Objective-C equivalent of Java's toString(). ...

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 usually returns NSRects that are clearly wrong, from my perspective. I have a program wit...

Is there an overview of all codes that can be used inside NSLog()?

i.e. %@ for strings, %f for doubles... I don't know the word for these placeholders but it would be great to have list for how to print booleans and other values. ...

NSLog(...) improper format specifier affects other variables?

I recently wasted about half an hour tracking down this odd behavior in NSLog(...): NSString *text = @"abc"; long long num = 123; NSLog(@"num=%lld, text=%@",num,text); //(A) NSLog(@"num=%d, text=%@",num,text); //(B) Line (A) prints the expected "num=123, text=abc", but line (B) prints "num=123, text=(null)". Obviously, printing a lon...

Objective-C NSString: strange characters when logging

Hey all, I'm a total noob when it comes to Objective-C / iPhone development. I'm trying to pull in text from a SQLite DB. I have a while loop that looks like this: while(sqlite3_step(selectstmt) == SQLITE_ROW) { And within that loop, this prints to the log just fine: NSLog(@"Text: %s",sqlite3_column_text(selectstmt, 1)); This does...

iphone nslog corrupted data

Hi I am having a weird problem with variable values. This is the code (it is part of a class method): MyAppDelegate *pDelegate = [[UIApplication sharedApplication] delegate]; SomeDictionaryData *appData = [pDelegate.theData retain]; NSLog(@"my instance var: %@",cardIndex); // outputs "my instance var: 4" NSDictionary *currentCard = [...

Generating a String from CLLocationDegrees, e.g. in NSLog or StringWithFormat.

Hello Stacked-Experts! My question: How to generate a string from a CLLocationDegrees value? Failed attempts: 1. NSLog(@"Value: %f", currentLocation.coordinate.latitude); //Tried with all NSLog specifiers. 2. NSNumber *tmp = [[NSNumber alloc] initWithDouble:currentLocation.coordinate.latitude]; 3. NSString *tmp = [[NSString alloc] ini...

Printing Instance ID to NSLog?

In the dealloc method for a class how would I print out the ID (or some other unique identifier) for the instance being deallocated? - (void)dealloc { NSLog(@"_deallocing: ??"); [super dealloc]; } Is this possible? I am just trying to get a little more feedback in the console as an aid to learning. many thanks -gary- ...

Can you send retain counts to NSLog to aid learning?

Just curious if there is anyway to display an objects retain count using NSLog. I just want to print them out to console to help learn how retain/release is working in some simple code? cheers -gary- ...

question concerning NSLog output %i, %d

I have question concerning a function I created. I would like to show the timeinterval in my console output. -(void)MyTimeInterval:(id)sender { NSDate *then = [NSDate date]; NSDate *now = [NSDate date]; NSTimeInterval interval = [now timeIntervalSinceDate:then]; NSLog(@"let me see the timeinterval between now and th...

NSLog 10b meaning?

Whenever I use NSLog(), it always shows this mysterious "10b" next to the process ID. I know that this is tied somehow to the thread where the NSLog() call was made, but what exactly does it mean? When I try NSLog() from a different thread in the same process, I will get values like 1003, 1103, and 1403. Here is the "Hello, World!" outpu...