格式字符串不是字符串文字(可能不安全)
我的代码是:
[tweetViewController setInitialText:[NSString stringWithFormat:self.url]];
Run Code Online (Sandbox Code Playgroud)
当您只使用字符串文字(通常是格式字符串)作为此方法的参数时,您正在使用变量时收到此警告.
如果您不想使用格式字符串,请不要使用该方法并使用以下absoluteString
方法NSURL
:
[tweetViewController setInitialText:[self.url absoluteString]];
Run Code Online (Sandbox Code Playgroud)
或者,如果您确实要使用格式方法,请使用格式字符串:
[tweetViewController setInitialText:[NSString stringWithFormat:@"URL: %@", [self.url absoluteString]];
Run Code Online (Sandbox Code Playgroud)
刚开始使用self.url
的参数为%@
将使用description
方法上NSURL
可能返回不同的结果,如果苹果不断改变这种方法的结果.
归档时间: |
|
查看次数: |
229 次 |
最近记录: |