尽管我们有很多人问过同样的问题,但没有一个答案有助于解决我的问题。所以这是我的代码,
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *text = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@", text);
//The NSJSONSerialization method to transform the NSData responseObject into a dictionnary does work
NSJSONSerialization *jsonResponse = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
//This NSLog makes the app crash with an unrecognized selector sent error
NSLog(@"JSON: %@",jsonResponse);
NSArray *result1=(NSArray *)[jsonResponse valueForKeyPath:@"result"];
NSLog(@"result1: %@",result1);
NSMutableString *shipPrice =[[NSMutableString alloc]init];
NSMutableString *freeLimitString =[[NSMutableString alloc]init];
if(result1!=Nil && ![result1 count]==0)
{
for (int i=0; i<result1.count; i++)
{
NSNumber *totalShippingPrice = [[result1 objectAtIndex:i] valueForKeyPath:@"totalShippingPrice"];
if( totalShippingPrice != nil && totalShippingPrice && [totalShippingPrice isEqualToNumber:0]&& [totalShippingPrice intValue]==0) // ISSUE LINE
{
shipPrice = (NSMutableString*)@"FREE";
} } } }
我保留了断点,并且它确实发生在上面的这一行中。我是新手AFNetworking
。我不知道如何解决它。帮助我提供工作代码示例:) 谢谢