Quote:
Originally Posted by jcc
Hi,
I have an NSMutableArray that displays a sidebar of various images.I use the following code to notify me of what image was tapped and at what index it was located:
Code:
if ([myArray objectAtIndex:anIndex] == [NSNumber numberWithInt:1]){
NSLog(@"Touched image at index: %u", anIndex);
NSLog(@"Touched image at 1);
} else if if ([myArray objectAtIndex:anIndex] == [NSNumber numberWithInt:2]){
NSLog(@"Touched image at index: %u", anIndex);
NSLog(@"Touched image at 2);
}...etc.
The problem I am facing is that I am able to recognize when the user has selected an image up to [NSNumber numberWithInt:12]...but anything higher than 12 the process stops working. Anyone have a clue what might be going on?
Thanks!
|
Not entirely clear from the snippet you posted. What makes you say the "process stops working"?
What is the size of your array? Keep in mind the index starts at 0.
Also, how many sections do you have? On iOS, an NSIndexPath object has both a row and a section property. When "-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath" is called, then, you need to account for both section and row.
Hope this helps.
EDIT: It also occurs to me that you are testing whether the object contained at
anIndex matches some number. This is different than testing whether or not an object exists at that index.