Ios 错误域=NSCOCAERRORDOMAIN代码=3840“;操作无法’;不可能完成
我试图得到json api的响应,但我在代码中发现了这种类型的错误,所以,请帮助我解决这个问题 错误:错误域=NSCOCAERRORDOMAIN代码=3840“操作 无法完成。(Cocoa错误3840。)(JSON文本未启动 使用数组或对象,并选择允许不设置片段。) UserInfo=0x7fed834422c0{NSDebugDescription=JSON文本未启动 具有数组或对象,并具有允许不设置片段的选项。, NSUnderlyingError=0x7fed837c2790“请求失败:内部服务器 错误(500)“}Ios 错误域=NSCOCAERRORDOMAIN代码=3840“;操作无法’;不可能完成,ios,objective-c,json,web-services,Ios,Objective C,Json,Web Services,我试图得到json api的响应,但我在代码中发现了这种类型的错误,所以,请帮助我解决这个问题 错误:错误域=NSCOCAERRORDOMAIN代码=3840“操作 无法完成。(Cocoa错误3840。)(JSON文本未启动 使用数组或对象,并选择允许不设置片段。) UserInfo=0x7fed834422c0{NSDebugDescription=JSON文本未启动 具有数组或对象,并具有允许不设置片段的选项。, NSUnderlyingError=0x7fed837c2790“请求失败:内
从错误消息中,从webservice返回的数据不是正确的json格式。你可以发布来自web服务的数据吗?是的,我将发布数据JSON:{feed=({“comment_count=”;“like_count=”;“like_type=”;“post_datetime”=“2015-11-14 12:02:41”;“post_heading”=Maruti;“post_id”=656;“post_image”=“4640321965.png”;“post_status”=A;“post_type”=0;“user_fname”=Kush;“user_id”=38;“user_lname”=“Ghodasara CMT,CFP”;“user_profile”=“7868630525.jpg”;)正在查看您的代码..等待,谢谢
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setValue:[[NSUserDefaults standardUserDefaults] objectForKey:@"UID"] forKey:@"user_id"];
[params setValue:self.strPostID forKey:@"post_id"];
[manager POST:[NSString stringWithFormat:@"%@webservices/post/loaddetails", API_URL] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"JSON: %@", [[responseObject objectForKey:@"feed"] objectAtIndex:0]);
NSDictionary *dict = [[responseObject objectForKey:@"feed"] objectAtIndex:0];
if (![[dict objectForKey:@"post_image"] isEqualToString:@""])
{
NSArray *arrTemp = [[dict objectForKey:@"post_image"] componentsSeparatedByString:@"."];
if ([[arrTemp objectAtIndex:1] isEqualToString:@"gif"])
{
[controller setInitialText:@"Hi,"];
//[controller addURL:[NSURL URLWithString:imgViewPost.imageURL]];
// [controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];
[controller addImage:[UIImage animatedImageWithAnimatedGIFURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@images/postimage/%@",API_URL,[dict objectForKey:@"post_image"]]]]];
[self presentViewController:controller animated:YES completion:Nil];
}
else
{
[controller setInitialText:@"First post from my iPhone app"];
//[controller addURL:[NSURL URLWithString:imgViewPost.imageURL]];
// [controller addImage:[UIImage imageNamed:@"socialsharing-facebook-image.jpg"]];
[controller addURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@images/postimage/%@",API_URL,[dict objectForKey:@"post_image"]]]];
[self presentViewController:controller animated:YES completion:Nil];
}
}
dict = nil;
[[AppDelegate sharedAppDelegate] hideProgress];
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
[[AppDelegate sharedAppDelegate] hideProgress];
NSLog(@"Error: %@", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
alert = nil;
}];