Edited to add code:
I am having an issue with indexOfObject. I am using the user selection from one array to choose and display objects from two other arrays. I first get the index of the object they choose and then use that to get the objectAtIndex from the other two arrays. I know this is very basic stuff, and I have done this before, but i have never experienced an issue like this one...
When the string in the array begins with a letter (a, b, c...) everything works fine. When the string begins with a number, the indexOfObject comes back with a ridiculously long number and crashes the app. The array that the users choose are age groups, so if they choose Premature, Newborn, adult female, or adult male everything works fine. If they choose 1 Year, 2 Year, 4 Year, etc. The app crashes.
This is my code (i changed the names of variables and functions/methods)
This is what is returned from a separate table view
- (void)ageGroupPicked:(NSString *)age {
//Set the text for the ageGroupLabel passed from ageTableView
ageGroupLabel.text = [NSString stringWithFormat:@"%@", age];
//Pass the string to the displayResults method
[self displayResults:age];
}
(void)displayResults:(NSString *)display {
// Set the variable pAge to the array index of the type from the ageGroupArray NSInteger pAge = [self.ageGroupArray indexOfObject:display];
// Use pAge to set the text of the resultsOneLabel self.resultsOneArray.text = [self.resultsOneArray objectAtIndex:pAge];
// Use pAge to set the text of the resultsTwoLabel self.resultsTwoLabel.text = [self.resultsTwoArray objectAtIndex:pAge];
}
I am not a full-time programmer, so go easy on me.
NSNotFound, simply meaning the object you are looking for was not found. Can you reproduce the problem on a small code sample? (See sscce.org for a guide.)