iOS网络请求传入数组

iOS网络请求传入数组

之前做项目的时候,后台要求传入数组,用AFN传入字典,代码入下:



          NSDictionary *parameter = [ NSDictionary dictionary];
            
          NSArray *arr = @[parameter];
            
          NSError *parseError = nil;

          NSData *jsonData = [NSJSONSerialization dataWithJSONObject:arr options:NSJSONWritingPrettyPrinted  error:&parseError];
            
          NSString *jsonstr =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
            
          NSData *objectData = [jsonstr dataUsingEncoding:NSUTF8StringEncoding];
            
          NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:objectData
                                     
                                                                    options:NSJSONReadingMutableContainers
                                     
                                                                      error:&parseError];

你可能感兴趣的:(iOS)