Tae Chatnaratanakun Tae Chatnaratanakun - 25 days ago 13
Objective-C Question

NSData dataWithContentsOfURL are null after update Xcode 6.4 to Xcode 7.0

Before I update Xcode version 6.4 it still work fine.

here is my code

- (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];


Here is the link to see the image from the NSLog.

enter image description here

Answer

I suspect you also updated to iOS 9, if so that is the problem.

See: App Transport Security Technote

The solution is to up date the server to https TLS 1.2 and forward security.

Another solution is to whitelist the url on the app plist or even if necessary allow all http connections. This reduces the connection security, the best approach is to update the server.