ios 後臺資料請求AFNetwork常遇見的1016錯誤與3840錯誤的解決方法
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html”];//1016錯誤解決方法,僅此一句話
manager.requestSerializer=[AFHTTPRequestSerializer serializer];
manager.responseSerializer=[AFHTTPResponseSerializer serializer];//(這種顏色的字是3840錯誤解決方法,共需要兩部分,這是第一步)
NSString *uid= [[NSUserDefaults standardUserDefaults] stringForKey:@"uid"];
NSString *bid=[[NSUserDefaults standardUserDefaults] stringForKey:@"bid"];
NSDictionary *parameters = @{@"uid":uid,@"bid":bid};
NSLog(@"%@",uid);
//你的介面地址
NSString *url=@"http://haiying.xushinet.com/like/member/";
//傳送請求.
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];//(3840錯誤解決方法第二步)
NSLog(@"關注:%@",dic);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];