NSURLConnection mit Blöcken
Ich bin mit
[NSURLConnection connectionWithRequest:req delegate:self];
und dann benutze ich
-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace;
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response;
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
-(void)connectionDidFinishLoading:(NSURLConnection *)connection;
Daten laden. Alles ist ok und funktioniert gut, aber ich weiß nicht, wie die Schönheit dieser code )
Ich möchte die Blöcke zu machen, mein code sieht wie folgt aus:
[myConnection sendData:data
successBlock:^(void){NSLog(@"success");}
errorBlock:^(NSError * error){NSLog(@"error.description: %@", error.description);}];
ist es möglich, mit NSURLConnection mit Blöcken?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich benutze diese Klasse:
Den
MyConnection.h
Und die
MyConnection.m
verwendet werden:
Er basiert auf dem code, Der Big Nerd Ranch verwendet auf seinem Buch.
Ich hoffe, es wird hilfreich sein.