【发布时间】:2013-09-17 20:29:52
【问题描述】:
我有一个 iOS 应用程序,它从该 URL 下载 JSON 提要:
https://www.googleapis.com/youtube/v3/activities?part=snippet%2CcontentDetails&home=true&maxResults=50&access_token=%@
我将 URL 存储在 NSString 中以供以后使用。我还在 URL 的末尾添加了一个 NSString,其中包含我用于 OAuth 身份验证的访问令牌(因此 %@ 在 URL 的最后)。
这是我存储 URL 的方式:
NSString *pre_yt_user_url = [NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/activities?part=snippet%2CcontentDetails&home=true&maxResults=50&access_token=%@", token_youtube];
如您所见,部分 URL 有一个 %2C
这会导致警告并使我的 iOS 应用程序崩溃!!
这是我收到的警告:
Format specifies type 'unsigned-short' but the argument has type NSString
和:
More % conversions than data arguments
我在这里做错了什么?我不能将 URL 存储在字符串中吗??
谢谢,丹。
【问题讨论】:
标签: ios cocoa-touch url nsstring nsstringencoding