I have a NSObject class in which I am sending a NSDictionary object too, the class object then sets all the entries in the NSDictionary to their native types that are variables in the NSObject class.
I would then like to pass this NSObject class into its own NSMutableArray however my app is crashing when this happens.
below is the code calling the NSObject Class and then trying to set it into a NSMutableArray.
NSArray *filteredArray = parsedDataArrayOfDictionaries; //dictionary entries are currently in nsstring format
SearchResultList *searchResultList = [[SearchResultList alloc]init];
NSMutableArray *testArray = [[NSMutableArray alloc] init];
int myCount = 0;
while (myCount <= [filteredArray count]) {
//call class and pass current NSDictionary in array[myCount]
[searchResultList assignSearchData:filteredArray[myCount]];
searchResultList = (SearchResultList*)[testingDic objectForKey:@"myObject"];
testArray[myCount] = searchResultList; //create array of nsobjectclassed, this is also where the app fails
NSLog(@"%@", testArray[myCount]);
}
Hopefully this is making some sense, I am getting abit lost in the middle of the while statements… I know I need to get back the NSObject Class then assign it to an array.. but im just not sure how to do this, any help would be greatly appreciated.
You are exceeding the size of the array
filteredArrayshould read
as the count of an array is one higher than the last object’s index, as the indices starts at 0.
honestly I am not sure, what you are trying to achieve, but you should consider to use fast enumeration instead of the while statement
or even fancier block-based enumeration