I’m brainfarting here. So I have a method that looks through a NSMutableArray that is a property of another class. The objects are NSString. In the debugger I see it says NSCFString for the object I’m trying to add to an array. So I basically do this:
- (NSArray *)GetFileNames {
NSMutableArray *fileNameArray = [[[NSArray alloc] init] autorelease];
for (NSString *str in self.ParentVC.SelectedOptions) {
[fileNameArray addObject:str];
NSLog(@"%@", str); // this works fine
}
return fileNameArray;
}
And I call this function somewhere else by:
NSArray *fileNameArray = [[NSArray alloc] initWithArray:[self GetFileNames]];
But for some reason, I get the unrecognized selector sent to instance and it stops on this line. Am I doing something wrong? Any tips to try to troubleshoot the problem? I already checked the self.ParentVC.SelectedOptions and that shows my NSCFString or NSCFStrings I want. Anything I can do in Instruments for this? Thanks.
Replace the second line with
The real type of the object is what you allocate, not what you declare. In the posted code, the array is not mutable.