當我呼叫以下方法_productName.text = _productInfo.Name
代碼在這裏停止並通過斷點調試拋出錯誤。***終止應用程序,由於未捕獲異常'NSInvalidArgumentException',原因:' - [__ NSDictionaryM名稱]:無法識別的選擇器發送到實例
請指導我....
謝謝!這裏是我的代碼:
-(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];
}
貴'OnGoProducts'類有一個'Name'財產? – fiddler
嘗試此 _productName.text = [NSString的stringWithFormat:@ 「%@」,_ productInfo.Name]; –
Srija首先你必須檢查你的字典中是否有名字。在此之前,向我展示你得到的迴應。 – user3182143