mercredi 9 mars 2016

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM Name]: unrecognized selector sent to instance

When i call below method _productName.text = _productInfo.Name the code stop here and throw the error by breakpoint debug.

Please guide me....

Thanks! Here is my code:

-(void)setProductInfo:(OnGoProducts*)prduct
{

    _productInfo = prduct;
    _productName.text = _productInfo.Name;
    NSDictionary* dict = [_productInfo.json objectFromJSONString];
    _productPrice.text = [dict objectForKey:@"MRP"];

    if([self.productInfo.type isEqualToString:@"Deals"])
    {
        [self.shownProperties addObject:@"Discount Value"];
        [self.shownProperties addObject:@"Discount Type"];
    }
    else
    {
        NSArray* allkeys = [dict allKeys];

        NSMutableSet* set = [NSMutableSet setWithArray:allkeys];

        NSArray* excludedKeys = @[@"ItemCode", @"id", @"Name", @"createdById", @"jobTypeId", @"createdByFullName", @"publicURL", @"ExpiredOn", @"Quantity", @"In_Stock", @"hrsOfOperation", @"createdOn",
                                  @"Image_Name", @"Image_URL", @"Latitude", @"Longitude", @"Attachments", @"Additional_Details", @"jobComments", @"Current_Job_Status,Category_Mall", @"MRP", @"Insights",
                                  @"Current_Job_StatusId", @"Next_Seq_Nos", @"CreatedSubJobs", @"Next_Job_Statuses", @"offersCount", @"productsCount", @"businessType", @"storeId", @"CategoryType", @"SubCategoryType", @"P3rdCategory", @"Category_Mall", @"PackageName",@"Current_Job_Status", @"jobTypeName",@"Units", @"guestUserId", @"guestUserEmail", @"Image"];

        NSSet* set1 = [NSSet setWithArray:excludedKeys];

        [set minusSet:set1];

        self.shownProperties = [set allObjects];
    }

    NSMutableArray* excludedKeys = [NSMutableArray array];
    for(int index = 0; index < self.shownProperties.count; ++index)
    {
        NSString* value = [dict objectForKey:[self.shownProperties objectAtIndex:index]];
        if(!value || ![value isKindOfClass:[NSString class]])
        {
            [excludedKeys addObject:[self.shownProperties objectAtIndex:index]];
        }
        if([value isKindOfClass:[NSString class]])
        {
            value = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
            if(value.length <= 0)
            {
                [excludedKeys addObject:[self.shownProperties objectAtIndex:index]];
            }
        }

    }

    NSSet* set1 = [NSSet setWithArray:excludedKeys];
    NSMutableSet* set = [NSMutableSet setWithArray:self.shownProperties];
    [set minusSet:set1];

    self.shownProperties = [set allObjects];

    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);

    [self.tableView reloadData];
}

Aucun commentaire:

Enregistrer un commentaire