Search code examples
objective-cnslog

How to print int * & unsigned int* in NSLog?


How to print int* (int pointer) and unsigned int* in log using NSLog?

- (int) doSomethingWith:(unsigned int)Msg withWparam:(unsigned int*)wParam withParameter:(int *) lParam
{
    NSLog(@"MSg:%d wParam:%u lParam:%u",Msg,wParam,lParam);
//not working
    return 1;
}

Warning: Format specifies type 'unsigned int' but the argument has type 'unsigned int *'


Solution

  • Use %d for int. And the parameters are pointers, so use * to access the values pointed to.

    NSLog(@"MSg:%d wParam:%u lParam:%d",Msg,*wParam,*lParam);