I working on grouped table view based work in that in that i want to convert the value of NSarray into integer for specifing to section value of numberOfRowsInSection but it throws expection on putting following code.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
int sec;
if (section == 0){ sec=6; }
else if(section == 1){ sec=6; }
else if(section == 2){
sec=[[rsvn_detail objectAtIndex:0] objectForKey:@"totalrecord"];
}
return sec;
}
Anybody help to recify it advance thanks for your suggestion
Regards, sathish
NSArray and NSDictionary can only hold Objective-C objects. An int
is not an object. It is likely the number is wrapped as an NSNumber. To convert an NSNumber back to an int
, call -intValue
:
sec = [[[rsvn_detail objectAtIndex:0] objectForKey:@"totalrecord"] intValue];
// ^^^^^^^^
Of course, make sure rsvn_detail
is really an NSArray of NSDictionary. Without -intValue
won't cause exceptions, only compiler warning/error will be raised.