Created
March 21, 2014 19:18
-
-
Save herzi/9693931 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURLSession* session; // wie du an die kommst, weißt du ja jetzt | |
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://example.com/"]]; | |
[request setValue:@"<ETag vom letzten Mal>" forHTTPHeaderField:@"If-None-Match"]; | |
[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { | |
if (![response isKindOfClass:[NSHTTPURLResponse class]]) { | |
error = [NSError errorWithDomain:@"FIXME" code:0 userInfo:@{@"unexpectedType": [[response class] description]}]; | |
} | |
NSHTTPURLResponse* http = (NSHTTPURLResponse*)response; | |
if (http.statusCode == 304) { | |
// keine änderung | |
return; | |
} else if (http.statusCode != 200) { | |
// fehlerbehandlung | |
return; | |
} | |
if (error) { | |
// fehlerbehandlung | |
return; | |
} | |
// antwort parsen | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment