Monday, 21 March 2011

Logging & Strings

Note: Different Log commands are required for Strings to ints.
Logging:


NSLog(@"%d", some_int );
NSLog(@"%f", some_double );
NSLog(@"%lld", some_long );
NSLog(@"%@", string_variable);

NSString* myNewString = [NSString stringWithFormat:@"%d", myInt];
double d = [myNewString doubleValue];
long long l = [myNewString longLongValue]; //long long = 64 bit


string conversions

Another cool logging trick - this prints the function name and line etc:

NSLog(@"%s %d %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, __FUNCTION__);

No comments:

Post a Comment