Reputation: 3137
Is that possible to return as number of rows in section the value(and not the count) of an NSMutableArray
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"number of rows in section: %@",[arrayofNombre objectAtIndex:section]);//it prints the right value
return [arrayofNombre objectAtIndex:section];
}
The application just crashes, and when I put a constant value (return 2 for example), the application runs but it gives not the expected result. I'm surely missing something. Thank you for helping.
Upvotes: 0
Views: 297
Reputation: 35384
If your array holds instances of NSNumber you need to convert the object to NSInteger:
return [[arrayofNombre objectAtIndex:section] integerValue];
Upvotes: 1
Reputation: 2411
It seems that you're returning an NSNumber, while the method is expecting an NSInteger. You should convert the NSNumber as follows.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"number of rows in section: %@",[arrayofNombre objectAtIndex:section]);//it prints the right value
return [[arrayofNombre objectAtIndex:section] intValue];
}
Upvotes: 5
Reputation: 9414
No. You are returning an NSInteger. You need to explicitly declare a property to hold the value if you choose.
Upvotes: 1