NSDictionary オブジェクトを含む NSArray があります。
値の選択に基づいてオブジェクトをフィルター処理する必要があるため、フィルター処理する値の配列を作成し、predicatewithformat を使用してオブジェクトの配列をフィードしました。
これは一種の機能ですが、奇妙なことに、空の配列を返す必要があることがわかっている状況では、そこにあってはならない単一のオブジェクトを取得しています。
フィルター値の配列の値をログアウトしました。オブジェクトの id_str に対応するキーが含まれていることがはっきりとわかるので、返されるべきではありません。
以下は私が使用しているコードです。私が間違っている場所のポインタは非常に役に立ちます!
//Create new fetch request
NSFetchRequest *request = [[NSFetchRequest alloc] init];
//Set new predicate to only fetch tweets that have been favourited
NSPredicate *filterFavourite = [NSPredicate predicateWithFormat:@"favouriteTweet == 'YES'"];
//Setup the Request
[request setEntity:[NSEntityDescription entityForName:@"Tweet" inManagedObjectContext:_managedObjectContext]];
//Assign the predicate to the fetch request
[request setPredicate:filterFavourite];
NSError *error = nil;
//Create an array from the returned objects
NSArray *favouriteTweets = [_managedObjectContext executeFetchRequest:request error:&error];
NSAssert2(favouriteTweets != nil && error == nil, @"Error fetching events: %@\n%@", [error localizedDescription], [error userInfo]);
//Create a new array containing just the tweet ID's we are looking for
NSArray *favouriteTweetsID = [favouriteTweets valueForKey:@"tweetID"];
NSLog(@"%@", favouriteTweetsID);
//Create a new predicate which will take our array of tweet ID's
NSPredicate *filterFavouritsearchPredicate = [NSPredicate predicateWithFormat:@"(id_str != %@)" argumentArray:favouriteTweetsID];
//Filter our array of tweet dictionary objects using the array of tweet id's we created
NSArray *filteredTweets = [self.timelineStatuses filteredArrayUsingPredicate:filterFavouritsearchPredicate];
//Send those tweets out to be processed and added to core data
[self processNewTweets:filteredTweets];
NSLog(@"Update Favoutited Tweets: %@", filteredTweets);