2013-01-09 72 views
0

我做了很多的搜索,我無法找到解決我的問題,AFNetworking從POST請求不工作與iOS 5.1

我試圖讓使用afnetworing庫JSON數據的形式POST請求,一切工作正常在iOS 6。

當我在IOS測試過5.1的版本,形式POST請求沒有被觸發,或一些錯誤是發生

下面是我的要求會看起來像:

 id paramString; 
     if(![data isKindOfClass:[NSString class]]) 
     paramString = [Helper objectToJsonString:data AND:0]; // converts nsdictionary to  string 
     else 
      paramString = data; 

     NSLog(@"Param String => %@ \n",paramString); 

     AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL  URLWithString:urlString]]; 
     [httpClient setParameterEncoding:AFFormURLParameterEncoding]; 

     NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:nil parameters:paramString]; 
     [request setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData]; 
     [request setTimeoutInterval:30]; 

     [self makeJsonRequest:requestedView withSelector:callBackFunction AND:request]; 

    AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc]  initWithRequest:request]; 
      [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,  id responseObject) { 
NSLog(@" response data => %@",json); 
    } 

     failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
    NSLog(@" error=> %@",error); 
}]; 

爲iOS 6,以下是我的迴應: Json Response => {0} {0}詳細=「過程創建!」; 迴應=成功; }

但iOS 5中,我的反應看起來像 JSON響應=> {}

如果它不是一個有效的形式POST請求或請求體不包含任何意味着我們的服務器會返回emtpy響應

一點要注意:一切工作正常的iOS 6

我使用我在此代碼有關iOS 6的任何功能

任何人都可以幫助我解決這個問題!

在此先感謝!

回答

0

嗨,我發現問題我自己,實際上,問題NSUUID這是一個IOS 6功能,我試圖在iOS 5中使用它,因此沒有在我們的服務中找到所需的參數我收到{}響應。