HDd*_*per 29 objective-c nslog
如何打印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;
}
Run Code Online (Sandbox Code Playgroud)
警告: Format specifies type 'unsigned int' but the argument has type 'unsigned int *'
Jor*_*ers 45
使用%d了int.参数是指针,因此用于*访问指向的值.
NSLog(@"MSg:%d wParam:%u lParam:%d",Msg,*wParam,*lParam);
Run Code Online (Sandbox Code Playgroud)
Vai*_*rma 10
%@是为了对象.BOOL不是一个对象.你应该用%d.
在数据类型的基础上%@改变如下
For Strings you use %@
For int you use %i
For float you use %f
For double you use %lf
Run Code Online (Sandbox Code Playgroud)