2014-03-19 41 views
0

我想在afnetworking
做一個POST請求,這是我的代碼絲毫ASI:後到服務器,更換ASIFormDataRequest到AFnetworking

NSURL *mainurl = [NSURL URLWithString:@"xxxx/api/xxx/"]; 

    ASIFormDataRequest *requestt = [ASIFormDataRequest requestWithURL:mainurl]; 

    [requestt addPostValue:GETUnicidentifire forKey:@"UniqueId"]; 
    [requestt addPostValue:JsonOrderDetail forKey:@"jsonProduct"]; 
    [requestt addPostValue:BranchId   forKey:@"BranchId"]; 
    [requestt addPostValue:OrderToTime  forKey:@"OrderToTime"]; 

    [requestt setCompletionBlock:^{ 
     // Process the response 




    }]; 
    [requestt setFailedBlock:^{ 
     NSError *error = [requestt error]; 

我該怎麼辦在AFnetworking相同丁字褲?

回答

1

沒有一個確切的答案,但這裏是從我的應用程序非常相似的POST請求:

-(void)setGpsLocation:(CLLocation*)location success:(TPScopeInterfaceSuccess)success failure:(TPScopeInterfaceFailure)failure 
{ 
    [_manager POST:@"gps/" 
     parameters:@{ 
        @"lat":@(location.coordinate.latitude), 
        @"lon":@(location.coordinate.longitude), 
        @"height":@(location.altitude), 
        } 
    constructingBodyWithBlock:nil 
      success:success 
      failure:failure]; 
} 

_manager被初始化爲AFHTTPRequestOperationManager的一個實例:

_manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:@"http://192.168.1.1/"]]; 
相關問題