I've looked at lots of questions about NS(Mutable)Arrays. I guess I am not grokking the concept, or the questions don't seem relevant.
What I' trying to do is the following:
Incoming Array 1:
Name Code Start time End Time etc
Incoming Array 2
Code Ordinal
What I want:
Ordinal Name Code Start time End Time etc
This is my code at present:
int i=0;
for (i=0; i < stationListArray.count; i++) {
NSString *slCodeString = [stationListArray[i] valueForKey:@"Code"];
NSLog(@"slCodeString: %@", slCodeString);
int j=0;
for (j=0; j< lineSequenceArray.count; j++) {
NSString *lsCodeString = [lineSequenceArray[j]valueForKey:@"StationCode"];
NSLog(@"lsCodeString: %@", lsCodeString);
if ([slCodeString isEqualToString:lsCodeString]) {
NSLog(@"match");
NSString *ordinalString = [lineSequenceArray[j] valueForKey:@"SeqNum"];
NSLog(@"ordinalString: %@", ordinalString);
[stationListArray[i] addObject:ordinalString]; <------
}
}
}
I'm logging the values and they return correctly. The compiler doesn't like the last statement. I get this error:
[__NSCFDictionary addObject:]: unrecognized selector sent to instance 0x7f9f63e13c30
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary addObject:]: unrecognized selector sent to instance 0x7f9f63e13c30'
Here is an excerpt from the StationListArray:
(
{
Address = {
City = Greenbelt;
State = MD;
Street = ".....";
Zip = 20740;
};
Code = E10;
Lat = "39.0111458605";
Lon = "-76.9110575731";
Name = Greenbelt;
}
)
stationListArray[i]is aNSDictionary, not aNSArray.insertObject:atIndex:method documented in developer.apple.com/library/mac/documentation/Cocoa/Reference/…