【发布时间】:2012-10-08 04:46:44
【问题描述】:
我有这个非常简单的代码:
PO(URLString);
url = [NSURL URLWithString:URLString];
PO(url);
NSData * data=[NSData dataWithContentsOfURL:url];
(PO() 是我打印东西的宏。)
它大部分时间都有效。这是输出:
2012-10-08 11:39:28.187 BadgerNew[2475:5007] <0x1f5321f0 BGCRBusinessForDisplay.m:(113)> URLString: http://id.openrice.com/UserPhoto/photo/0/U/0005Z29E131A230CBA4A42n.jpg
2012-10-08 11:39:28.193 BadgerNew[2475:5007] <0x1f5321f0 BGCRBusinessForDisplay.m:(115)> url: http://id.openrice.com/UserPhoto/photo/0/U/0005Z29E131A230CBA4A42n.jpg
2012-10-08 11:39:30.191 BadgerNew[2475:6b03] <0x1f529f00 BGCRBusinessForDisplay.m:(113)> URLString: http://maps.googleapis.com/maps/api/staticmap?&zoom=16&size=160x160&maptype=roadmap&sensor=true¢er=-6.187900,106.775429&markers=size:small|color:blue|-6.187900,106.775429
2012-10-08 11:39:30.196 BadgerNew[2475:6b03] <0x1f529f00 BGCRBusinessForDisplay.m:(115)> url: (null)
如您所见,它适用于 http://id.openrice.com/UserPhoto/photo/0/U/0005Z29E131A230CBA4A42n.jpg,但在 http://maps.googleapis.com/maps/api/staticmap?&zoom=16&size=160x160&maptype=roadmap&sensor=true¢er=-6.187900,106.775429&markers=size:small|color:blue|-6.187900,106.775429 上却失败了
也许问题是 |在 Google 网址中。那我该怎么办呢?
【问题讨论】:
-
您可以首先使用 URL 缩短器使您的 URL “有效”。我成功地使用bit.ly developer API 自动执行此操作。
标签: objective-c nsurl