-
StackOverflow 文件
-
Objective-C Language 教程
-
NSPredicate
-
按名稱過濾
NSArray *array = @[
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB71",
@"title": @"Jackie Chan Strike Movie",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB72",
@"title": @"Sherlock homes",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @0
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB73",
@"title": @"Titanic",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB74",
@"title": @"Star Wars",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB75",
@"title": @"Pokemon",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @0
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB76",
@"title": @"Avatar",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB77",
@"title": @"Popey",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB78",
@"title": @"Tom and Jerry",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
},
@{
@"id": @"7CDF6D22-8D36-49C2-84FE-E31EECCECB79",
@"title": @"The wolf",
@"url": @"http://abc.com/playback.m3u8",
@"thumbnailURL": @"http://abc.com/thumbnail.png",
@"isMovie" : @1
}
];
// *** Case Insensitive comparision with excate title match ***
NSPredicate *filterByNameCIS = [NSPredicate predicateWithFormat:@"self.title LIKE[cd] %@",@"Tom and Jerry"];
NSLog(@"Filter By Name(CIS) : %@",[array filteredArrayUsingPredicate:filterByNameCIS]);