Translate

2012年6月13日 星期三

ASIHTTPRequest

ASIHTTPRequest
雖然作者已經沒在更新了但是我還是覺得不錯用
使用前記得要

#pragma mark -
#pragma mark ASIHTTPRequest delegate
- (void)requestFinished:(ASIHTTPRequest *)request
{
    NSString *responseString = [request responseString];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{

}


get直接給參數
例如

NSString *ip_url = [NSString stringWithFormat:@"%@%@", get_invitation_reward, AppDelegate.act_id]; NSURL *url = [NSURL URLWithString:ip_url]; request_list = [ASIHTTPRequest requestWithURL:url]; [request_list setDelegate:self]; [request_list startAsynchronous];



post逐一給參數
例如

NSURL *url = [NSURL URLWithString:set_reward_winner]; request_reward_winner = [ASIFormDataRequest requestWithURL:url]; [request_reward_winner setRequestMethod:@"POST"]; [request_reward_winner setPostValue:AppDelegate.act_id forKey:@"act_id"]; [request_reward_winner setPostValue:[[list_data objectAtIndex:select_row] objectForKey:@"code"] forKey:@"code"]; [request_reward_winner setPostValue:[prize_reward_id objectAtIndex:selectCom1Index] forKey:@"reward_id"]; [request_reward_winner setDelegate:self]; [request_reward_winner startAsynchronous];

沒有留言:

張貼留言