在Xcode 4.2(iOS 5)之前,我猜大家都和我一样很喜欢下面的调试输出写法:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
NSString *str = @ "Attention" ;
NSLog (str);
NSLog ([str stringByAppendingFormat:@ ", %@" , @ "Xcode 4.2 do not support this format!" ]);
NSLog ([ NSString stringWithFormat:@ "%@, Xcode 4.2 do not support this format!" , @ "Attention" ]);
NSException *exception = [ NSException exceptionWithName:@ "Attention"
reason:@ "Xcode 4.2 do not support this format!"
userInfo: nil ];
NSLog (exception);
|
但是在Xcode 4.2(iOS 5)之后,貌似苹果更新的编译器,出了支持ARC的Apple LLVM compiler 3.0。然后我发现每次编译,以前的这些输出都会产生一个warning(警告,黄色三角形)。
在StackOverflow和iPhone Dev SDK查找相关答案之后,发现在最新版的编译器里面NSLog为了安全,只接受格式化的字符串,因为NSLog底层也是用printf来格式化输出的。
所以上面的写法都会给出警告,可以把上面的写法修改为以下合法模式:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
NSString *str = @ "Attention" ;
NSLog (str);
NSLog (@ "%@" , str);
NSLog (str, nil );
NSLog ([str stringByAppendingFormat:@ ", %@" , @ "Xcode 4.2 do not support this format!" ]);
NSLog (@ "%@" , [str stringByAppendingFormat:@ ", %@" , @ "Xcode 4.2 do not support this format!" ]);
NSLog ([str stringByAppendingFormat:@ ", %@" , @ "Xcode 4.2 do not support this format!" ], nil );
NSLog ([ NSString stringWithFormat:@ "%@, Xcode 4.2 do not support this format!" , @ "Attention" ]);
NSLog (@ "%@, Xcode 4.2 do not support this format!" , @ "Attention" );
NSLog ([ NSString stringWithFormat:@ "%@, Xcode 4.2 do not support this format!" , @ "Attention" ], nil );
NSException *exception = [ NSException exceptionWithName:@ "Attention"
reason:@ "Xcode 4.2 do not support this format!"
userInfo: nil ];
NSLog (exception);
NSLog (@ "%@" , exception);
|
分享到:
相关推荐
001-glib-gdate-suppress-string-format-literal-warning.patch 001-glib-gdate-suppress-string-format-literal-warning.patch 001-glib-gdate-suppress-string-format-literal-warning.patch
项目中有个定时任务,每天取到一些表...EOL while scanning string literal: <string>, line 1, pos 7 google一下,这个异常造成的原因是字符串,引号没有成对出现,也就是类似下面的情况 复制代码 代码如下: str(
今天在写爬虫程序的时候由于要翻页,做除法分页的时候出现了 复制代码 代码如下: totalCount = ‘100’ totalPage = int(totalCount)/20 ValueError: invalid literal for int() with base 10的错误 网上同样的...
适用qt5.9 win 环境下 protobuf 3.16 源码加已编译的静态库
A library with 2 functions. StripChars() removes any ... SplitString() splits a string on one or more individual characters or on an instance of a string contained within the string you want to split.
ts-string-literal-enum-plugin 只需单击一下,即可将枚举转换为字符串文字枚举的工具。 建立 :red_heart_selector: 。用法安装作为VSCode扩展您可以看到 。作为打字稿插件安装套件yarn add ts-string-literal-enum-...
StringLiteral stringLiteral = ast.newStringLiteral(); stringLiteral.setLiteralValue("中国"); //将其作为引用方法参数 methodInvocation.arguments().add(stringLiteral); //创建变量 ...
mysql 数据库数据赋给js变量报unterminated string literal错误原因
编译ESP8266_RTOS_SDK 2.0.0文件出现错误,提示缺少lhal.a文件,添加后解决 附下载连接:https://github.com/esp8266/esp8266-wiki/blob/master/libs/libhal.a
string.sub(s, -3) will return the last 3 bytes of the string which is not necessarily the same as the last three characters of the string, and may or may not be a complete code. You could use the ...
The different mechanisms vary in terms of how a string is delimited and how much substitution is done on the literal’s content. Single-quoted string literals ('stuff ' and %q/stuff /) undergo the ...
> node_modules/cache-manager/lib/caching.js:28:21: warning: This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)...
Literal控件的例子
We use the if condition to check if the particular condition is true then it should perform a certain task, and if a particular condition is not true then it should do some other tasks. ...
'This is a simple Ruby string literal' 如果需要内放置一个单引号,单引号的字符串文字,在它前面加上一个反斜杠Ruby解释器不认为终止字符串: 'Won\'t you read O\'Reilly\'s book?' 反斜杠也可以转义另一个反...
Expected string literal (path), "*" or alias list. 或者 Source "@openzeppelin/contracts/token/ERC721/ERC721.sol" not found: File import callback not supported 回退版本是一个解决方案,这里给出插件以供...
文字池[pool of literal strings]和堆[heap]中的字符串对象。 一、引用变量与对象:除了一些早期的Java书籍和现在的垃圾书籍,人们都可以从中比较清楚地学习到两者的区别。A aa;语句声明一个类A的引用变量aa[我常常...
Literal控件的使用 自己在做网页的时候,总结的一点东西