nslog

What does NSLog actually do?

Hi, I am having a weird problem. I am using a method from Apple's private frameworks in my application. When I call it for the first time, it works. When I call it for the second time immediately without anything in between, it crashes. However, if I put NSLog between the two calls, it works wonderfully. So I try removing NSLog and puti...

iPhone Dev: How to get string format attributes like NSLog

Hi all, I'm trying to wrap NSLog function just to add some info every time I log something, but I have a problem. The NSLog declaration is void NSLog(NSString *format, ...) __attribute__((format(__NSString__,1,2))) this allow to have multiple parameters in call as NSLog(@"first %@ second %@ third %d,string,string,number); My decl...

sprintf fails spontaneously depending on what printf and NSLog calls there are.

Hello I have a bizarre problem with sprintf. Here's my code: void draw_number(int number,int height,int xpos,int ypos){ char string_buffer[5]; //5000 is the maximum score, hence 4 characters plus null character equals 5 printf("Number - %i\n",number); sprintf(string_buffer,"%i",number); //Get string printf("String - %s\n...

How to avoid "unused variable" compiler warnings with conditionally compiled NSLog replacements?

This comes out of my search for a smart variant of NSLog(). One key feature of BetterLog() is that the NSLog() replacement compiles out to nothing for release and distribution builds. The proposed solution (see eg http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code) is define a preprocess...

Display bytes in NSLog

Hi there How can I display these bytes in NSLog? const void *devTokenBytes = [devToken bytes]; Cheers Cyril ...

How do you get the variables passed into function using macros (objective c)

Does anyone know how to dynamically get all the variables values passed into a function for the sake of logging ? I'm looking for a simple way (like using a compiler macro) to be able to log the function, and the variable values passed into it (which will then be written to a log file so we can easily find inputs that cause functions to...

ObC: How to convert a memory pointer to dataP

Hi, I have a custom data container object of type RowOfPlayerData. When I try to display a RowOfPlayerData object in NSLog, the system doesn't know how to display it, so it just shows the address of the object. I am trying to figure out how i can display, in an NSLog statement, what is at that address so i can use the data. I am trying...

How to use printf with NSString

I need to use something like NSLog but without the timestamp and newline character, so I'm using printf. How can I use this with NSString? ...

Getting information about a class with NSLog

When I first started learning XCode I remember hearing something about how it has cool features to inspect an object and get information about its class. Now I need to use these cool features. How can I use NSLog to get class information about an object and other cool information about an object. ...

Weird Compilation Error on Xcode

Simple problem... I had some comments on my code and deleted them and got an error. After some hours I arrived at the source. This code works: switch (indexPath.row) { case 0: NSLog(@"case 0"); break; case 1: // Clients NSLog(@"case 1"); ViewClientListTableController *viewListTableController = [...

NSLog in submitted app

I had the misfortune of submitting an app with an NSLog still active. It very rarely fires, but I would like to know what are the chances of my app being rejected because of that? I am NOT asking how to supress NSLogs. I already know how to. It is just a stray NSLog which made it in by mistake. ...

[[NSDate alloc] init] returning date an hour in the past?

When I call NSDate *now = [[NSDate alloc] init]; in order to get the current date and time, I check it with: NSLog(@"Date now: %@", now); the date outputted is one hour in the past. 2010-10-08 12:04:38.227 MiniBf[1326:207] Now: 2010-10-08 11:04:38 GMT Is my time zone set incorrectly somewhere perhaps? Thanks! Micha...

How do I output a literal sequence with NSLog

I want NSLogto output a literal escape sequence, without treating it as a pattern. Take, for example NSLog(@"image%03d.jpg");, who's output I want to be the actual contents, image%03d.jpg instead of image000.jpg. I've tried various escape sequences like NSLog(@"image\\%03d.jpg");, NSLog(@"image\\%03\\d.jpg"); and NSLog(@"image%03\\d.jp...

How to make NSLog work with Python's logging module when using PyObjC?

I'm writing a Django-based webapp that imports a Cocoa framework via PyObjC. The Cocoa framework has NSLog() littered all through it and while I can see them when running the Django server in non-daemon mode, as soon as I go to daemon I simply lose all this useful NSLog() output. Is there any easy way to get NSLog stuff to bubble up in...

iphone nslog output format

Can someone tell me what the stuff in the [] is supposed to be in the log message below? I got this on my iphone app, and I have no idea where the message is coming from. My first guess would be a line number, but which file would it be in? 2010-10-19 08:56:12.006 Encore[376:6907] Thanks ...

How to dump NSHomeDirectory file listing to NSLog

Is there a quick way to spit out a directory listing for a specific folder in NSHomeDirectory? I'm playing with an example in ASIHTTPRequest that downloads an image via: [request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"totallyhotmilf.jpg"]]; I'd like...

printing int with specified nr of digits

I am trying to print out a 5 digit number as follows: int rdmNr = arc4random()%100000; NSLog(@"%i",rdmNr); I always would like to have 5 digit numbers. Example outputs should be: 00001 10544 00555 78801 But with the previous code I would also get 1 or 555 without 0s. I also tried %5i, but the I just get more white spaces. ...

How can I easily redirect the console output in a NSTextView?

Suppose you have the code of a Cocoa app which logs its own messages through NSlogs and printfs to the Console output. My goal is to redirect all this output into a separate NSWindow in a NSView. How can I achieve this in a way that minimizes the amount of code to rewrite makes it possible to revert back maximizes the reuse of written...

Xcode - HitTesting returns 3 times

Hey all! I have a UIView subclass where hitTest: withEvent: is overridden. Every time a hit test registers, the view logs its tag. Ex: Click Console: You Touched View: 3 You Touched View: 3 You Touched View: 3 My question: Why does it do it three times? I need it to trigger something other than an NSLog and I'm afraid that it will t...