如何打印int *& NSLog中的unsigned int *?

时间:2013-01-18 10:26:56

标签: objective-c nslog

如何使用int*在日志中打印unsigned int*(int指针)和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;
}

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

2 个答案:

答案 0 :(得分:43)

%d使用int。参数是指针,因此使用*来访问指向的值。

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

答案 1 :(得分:9)

%@用于对象。 BOOL不是对象。你应该使用%d 在数据类型%@的基础上更改如下

For Strings you use %@
For int  you use %i
For float you use %f
For double you use %lf