32

如何使用打印int*(int指针)和unsigned 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 *'

4

2 回答 2

51

用于. %d_ int而且参数是指针,所以*用来访问指向的值。

NSLog(@"MSg:%d wParam:%u lParam:%d",Msg,*wParam,*lParam);
于 2013-01-18T10:29:57.773 回答
14

%@是为对象。BOOL不是一个对象。你应该使用%d.
基于数据类型%@更改如下

For Strings you use %@
For int  you use %i
For float you use %f
For double you use %lf
于 2014-06-24T09:36:41.983 回答