libmx3 / mx3

a sample project showcasing/collecting cross platform techniques on mobile
MIT License
1.17k stars 149 forks source link

Deprecated: 'sendAsynchronousRequest:queue:completionHandler:' in iOS9 #76

Closed ItamarM closed 8 years ago

ItamarM commented 8 years ago

Should use NSURLSession (supported from iOS7).

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        if (error) {
            [callback onNetworkError];
        } else {
            int16_t httpCode = [(NSHTTPURLResponse*) response statusCode];
            NSString * strData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
            [callback onSuccess:httpCode data: strData];
        }
 }] resume];

Great example overall. Keep up the good work :+1:

skabbes commented 8 years ago

Thanks for letting me know! Do you mind putting up a PR?

skabbes commented 8 years ago

Fixed with: https://github.com/libmx3/mx3/commit/78627c6c4d0e290ab6e3c9d44a85fdd117d50834

ItamarM commented 8 years ago

@skabbes Sorry I was OOO. Thanks for closing it :+1: