Reputation: 1019
In my iphone application I have 4 cell in uiTable, and each cell having Integers values(10, 12, 13, 14).How to retrieve the integer value while I click on each cell? And how to put if condition to check whether the value of the cell is same or not? I.e.
if(cell value==condition){
}
Upvotes: 1
Views: 576
Reputation: 8069
In the didSelectRowAtIndexPath
method in your UITableViewController
simply extract the labels text value.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *s = [[[tableView cellForRowAtIndexPath:indexPath] textLabel] text];
NSLog(@"String is: %@", s);
int i = [s intValue];
NSLog(@"This is the int value: %d", i);
// Compare string or int to other value...
}
Upvotes: 1