ios http 认识



// tong bu request
NSURL *url = [NSURL URLWithString:@""];
ASIHttpRequest *request = [ASIHttpRequest requestWithURL:url];

[request startSynchronous];

NSError *error = [request error];

if (!error) {
NSString *string = [request responseString];
}


// yi bu request
NSURL *url = [NSURL URLWithString:@""];
ASIHttpRequest *request = [ASIHttpRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];


-(void)requestFinished:(ASIHttpRequest*)request
{
NSString *string = [request responseString];

NSData *data = [request responseData];

}


    -(void)requestFailed:(ASIHttpRequest*)request
    {
    NSError *error = [request error];
    }

你可能感兴趣的:(ios开发,经验)