Timur Mustafaev
Timur Mustafaev

Reputation: 4929

Work with objects in NSArray

I need to work with objects in NSMutableArray. I have NSMutableArray called "Albums" it contains objects "Album"

@interface Album : NSObject {   
    NSString *aid;
    NSString *title;
    NSString *ownerID;
}

I push few Album objects into "Albums" NSMutableArray, and i want to delete Album object where "title" field is "HelloWorld" for example or something else. How to do this?

Upvotes: 1

Views: 90

Answers (1)

Regexident
Regexident

Reputation: 29562

This should do:

NSArray *matchingObjects = [array filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self.title = %@", @"HelloWorld"]];
[array removeObjectsInArray:matchingObjects];

Upvotes: 3

Related Questions