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!
...
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 ...
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...
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...
Do you have any unique or special uses of NSLog you use for debugging?
...
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...
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.
...
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?
...
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...
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().
...
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...
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.
...
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...
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...
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 = [...
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...
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-
...
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-
...
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...
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...