Tony Arnold
Tony Arnold

Reputation: 2929

Filtering a RACSequence not working as expected

I'm trying to refresh a fetched array of objects using ReactiveCocoa, and I'd like to filter out results that have been deleted. I can't quite seem to get things working right — I expect that the filter would be passed each NSManagedObject in the trackSequence, but instead I see a _PFBatchFaultingArray object.

Can anyone shed any light on what I'm doing wrong? Thanks!

RACSequence *trackSequence = [documentContextUpdated map:^NSArray *(RACTuple *tuple) {
    return [DWFAbstractTrack MR_findAllSortedBy:DWFAbstractTrackAttributes.order ascending:YES inContext:tuple.second];
}].sequence;

RAC(self, tracks) = [trackSequence filter:^BOOL(NSManagedObject *managedObject) {
    return (NO == [managedObject isDeleted]);
}].signal;

Upvotes: 0

Views: 489

Answers (1)

Dave Lee
Dave Lee

Reputation: 6489

Looks like trackSequence is a RACSequence of NSArrays, not NSManagedObjects. Perhaps you want the -filter: in the -map:?

RAC(self, tracks) = [documentContextUpdated map:^NSArray *(RACTuple *tuple) {
    NSArray *tracks = [DWFAbstractTrack MR_findAllSortedBy:DWFAbstractTrackAttributes.order ascending:YES inContext:tuple.second];
    return [tracks.rac_sequence filter:^BOOL(NSManagedObject *managedObject) {
        return (NO == [managedObject isDeleted]);
    }].array;
}];

Upvotes: 1

Related Questions