Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串[currentTweet pic],它应该是图片的 URL(从 XML 文件解析)。问题是某些链接在 URL 中缺少“http://”,因此某些图片不会出现。如何在缺少的地方添加“http://”?
[currentTweet pic]
非常感谢任何帮助!谢谢
我假设您的意思是 aNSString这里,而不是 a NSURL。
NSString
NSURL
NSString *picURL = [currentTweet pic]; if (![picURL hasPrefix:@"http://"]) { picURL = [@"http://" stringByAppendingString:picURL]; }
不确定 twitter 是否曾经使用https过图片 url,但您可能还应该检查https://一下以确保。
https
https://