Copying a selected NSArray of Arrays to an NSArray
I have the following line:
[self.keys addObjectsFromArray:[newArray 开发者_开发知识库objectAtIndex:0]];
newArray is an array of arrays.
I want NSMutableArray keys to be the array at the first index of newArray.
what this is returning is zero when I should be getting two.
This is how newArray is built, and appears to look right when i debug it.
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", sSelectedCat];
NSArray *newArray = [[aDictionary allKeys] filteredArrayUsingPredicate: filterPredicate];
When I debug the code and hover over [newArray objectAtIndex:0] it is showing it as an NSCFString where I was hoping that it would be an NSArray.
What am I not seeing here?
newArray
is just a normal array of strings. filteredArrayUsingPredicate:
returns a single array. I think you probably want:
self.keys = [newArray mutableCopy];
This will make keys
an NSMutableArray containing your filtered keys.
精彩评论