使用NSLog进行调试 [英] Using NSLog for debugging

查看:110
本文介绍了使用NSLog进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Xcode中有以下代码片段:

  NSString * digit [[sender titlelabel] text]; 
NSLog([digit]);

我尝试构建应用程序,并收到以下警告消息: NSLog([digit]);

 警告:格式不是字符串文字,没有格式参数

你能建议我如何解决这个警告信息?消息实际上是什么意思?

解决方案

尝试这段代码:

  NSString * digit = [[sender titlelabel] text]; 
NSLog(@%@,digit);

该消息表示您使用数位变量。如果您没有发送任何消息 - 您不需要任何方括号。


I have the following code snippet in my Xcode:

NSString *digit [[sender titlelabel] text];
NSLog([digit]);

I tried to build the application and am getting the following warning message for the line NSLog([digit]);

Warning: Format not a string literal and no format arguments

Can you advise me how I can resolve this warning message? What does the message actually mean?

解决方案

Try this piece of code:

NSString *digit = [[sender titlelabel] text];
NSLog(@"%@", digit);

The message means that you have incorrect syntax for using the digit variable. If you're not sending it any message - you don't need any brackets.

这篇关于使用NSLog进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆