开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜