NSData dataWithContentsOfURL 在更新 Xcode 6.4 到 Xcode 7.0 后为空
NSData dataWithContentsOfURL are null after update Xcode 6.4 to Xcode 7.0
在我更新 Xcode 版本 6.4 之前它仍然可以正常工作。
这是我的代码
- (NSArray*)getData{
NSMutableArray *result = [[NSMutableArray alloc] init];
NSString *path = @"http://rmfl.nagasoftware.com/api/plant_by_season.php?lang_code=1&season_id=0";
if(path){
NSLog(@"%@",path);
NSURL *json = [NSURL URLWithString:path]; // jsonString
NSLog(@"URL is %@",[json absoluteString]);
NSData *jsonData = [NSData dataWithContentsOfURL:json];
这里是link从NSLog中看到的图像。
我怀疑你也更新到 iOS 9,如果是这样那就是问题所在。
参见:App Transport Security Technote
解决方案是将服务器更新为 https TLS 1.2 并转发安全性。
另一种解决方案是将 url 列入应用程序列表中的白名单,甚至在必要时允许所有 http 连接。这会降低连接安全性,最好的办法是更新服务器。
在我更新 Xcode 版本 6.4 之前它仍然可以正常工作。
这是我的代码
- (NSArray*)getData{
NSMutableArray *result = [[NSMutableArray alloc] init];
NSString *path = @"http://rmfl.nagasoftware.com/api/plant_by_season.php?lang_code=1&season_id=0";
if(path){
NSLog(@"%@",path);
NSURL *json = [NSURL URLWithString:path]; // jsonString
NSLog(@"URL is %@",[json absoluteString]);
NSData *jsonData = [NSData dataWithContentsOfURL:json];
这里是link从NSLog中看到的图像。
我怀疑你也更新到 iOS 9,如果是这样那就是问题所在。
参见:App Transport Security Technote
解决方案是将服务器更新为 https TLS 1.2 并转发安全性。
另一种解决方案是将 url 列入应用程序列表中的白名单,甚至在必要时允许所有 http 连接。这会降低连接安全性,最好的办法是更新服务器。