除了播放列表之外,我已经成功过滤了iCloud中我应用的每个部分的所有项目。在显示播放列表列表时,每个单元格内有一个子标题,用于读取该播放列表中的曲目数。问题是集合中的项目数是不正确的(尽管查询本身的项目总数是正确的。)
代码:
MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithBool:0] forProperty:MPMediaItemPropertyIsCloudItem comparisonType:MPMediaPredicateComparisonEqualTo];
MPMediaQuery *query = [MPMediaQuery playlistsQuery];
[query addFilterPredicate:predicate];
NSLog(@"(iCloud) Total number of items in query: %d",query.items.count);
int i=1;
for (MPMediaItemCollection *collection in query.collections) {
NSLog(@"(iCloud) Number of items in playlist %d: %d",i,collection.items.count);
i++;
}
MPMediaQuery *query2 = [MPMediaQuery playlistsQuery];
NSLog(@"(All) Total number of items in query: %d",query2.items.count);
i=0;
for (MPMediaItemCollection *collection in query2.collections) {
NSLog(@"(All) Number of items in playlist %d: %d",i,collection.items.count);
i++;
}
日志:
2013-02-16 20:46:08.904 MyApp[62357:907] (iCloud) Total number of items in query: 99
2013-02-16 20:46:08.918 MyApp[62357:907] (iCloud) Number of items in playlist 1: 5
2013-02-16 20:46:08.924 MyApp[62357:907] (iCloud) Number of items in playlist 2: 1
2013-02-16 20:46:08.930 MyApp[62357:907] (iCloud) Number of items in playlist 3: 19
2013-02-16 20:46:08.950 MyApp[62357:907] (iCloud) Number of items in playlist 4: 312
2013-02-16 20:46:08.956 MyApp[62357:907] (iCloud) Number of items in playlist 5: 5
2013-02-16 20:46:08.963 MyApp[62357:907] (iCloud) Number of items in playlist 6: 44
2013-02-16 20:46:09.003 MyApp[62357:907] (iCloud) Number of items in playlist 7: 16
2013-02-16 20:46:09.009 MyApp[62357:907] (iCloud) Number of items in playlist 8: 31
2013-02-16 20:46:09.015 MyApp[62357:907] (iCloud) Number of items in playlist 9: 90
2013-02-16 20:46:09.023 MyApp[62357:907] (iCloud) Number of items in playlist 10: 42
2013-02-16 20:46:09.069 MyApp[62357:907] (iCloud) Number of items in playlist 11: 296
2013-02-16 20:46:09.074 MyApp[62357:907] (iCloud) Number of items in playlist 12: 2
2013-02-16 20:46:09.134 MyApp[62357:907] (iCloud) Number of items in playlist 13: 25
2013-02-16 20:46:09.139 MyApp[62357:907] (iCloud) Number of items in playlist 14: 4
2013-02-16 20:46:09.143 MyApp[62357:907] (iCloud) Number of items in playlist 15: 1
2013-02-16 20:46:09.147 MyApp[62357:907] (iCloud) Number of items in playlist 16: 3
2013-02-16 20:46:09.153 MyApp[62357:907] (iCloud) Number of items in playlist 17: 19
2013-02-16 20:46:09.158 MyApp[62357:907] (iCloud) Number of items in playlist 18: 5
2013-02-16 20:46:09.162 MyApp[62357:907] (iCloud) Number of items in playlist 19: 7
2013-02-16 20:46:09.167 MyApp[62357:907] (iCloud) Number of items in playlist 20: 14
2013-02-16 20:46:09.177 MyApp[62357:907] (iCloud) Number of items in playlist 21: 247
2013-02-16 20:46:09.182 MyApp[62357:907] (iCloud) Number of items in playlist 22: 12
2013-02-16 20:46:09.186 MyApp[62357:907] (iCloud) Number of items in playlist 23: 2
2013-02-16 20:46:09.191 MyApp[62357:907] (iCloud) Number of items in playlist 24: 5
2013-02-16 20:46:09.195 MyApp[62357:907] (iCloud) Number of items in playlist 25: 2
2013-02-16 20:46:09.199 MyApp[62357:907] (iCloud) Number of items in playlist 26: 5
2013-02-16 20:46:09.213 MyApp[62357:907] (iCloud) Number of items in playlist 27: 239
2013-02-16 20:46:09.218 MyApp[62357:907] (iCloud) Number of items in playlist 28: 11
2013-02-16 20:46:09.265 MyApp[62357:907] (All) Total number of items in query: 3788
2013-02-16 20:46:09.269 MyApp[62357:907] (All) Number of items in playlist 0: 5
2013-02-16 20:46:09.270 MyApp[62357:907] (All) Number of items in playlist 1: 1
2013-02-16 20:46:09.271 MyApp[62357:907] (All) Number of items in playlist 2: 19
2013-02-16 20:46:09.272 MyApp[62357:907] (All) Number of items in playlist 3: 312
2013-02-16 20:46:09.272 MyApp[62357:907] (All) Number of items in playlist 4: 5
2013-02-16 20:46:09.273 MyApp[62357:907] (All) Number of items in playlist 5: 44
2013-02-16 20:46:09.274 MyApp[62357:907] (All) Number of items in playlist 6: 16
2013-02-16 20:46:09.275 MyApp[62357:907] (All) Number of items in playlist 7: 31
2013-02-16 20:46:09.275 MyApp[62357:907] (All) Number of items in playlist 8: 90
2013-02-16 20:46:09.276 MyApp[62357:907] (All) Number of items in playlist 9: 42
2013-02-16 20:46:09.277 MyApp[62357:907] (All) Number of items in playlist 10: 296
2013-02-16 20:46:09.277 MyApp[62357:907] (All) Number of items in playlist 11: 2
2013-02-16 20:46:09.278 MyApp[62357:907] (All) Number of items in playlist 12: 25
2013-02-16 20:46:09.279 MyApp[62357:907] (All) Number of items in playlist 13: 4
2013-02-16 20:46:09.279 MyApp[62357:907] (All) Number of items in playlist 14: 1
2013-02-16 20:46:09.280 MyApp[62357:907] (All) Number of items in playlist 15: 3
2013-02-16 20:46:09.281 MyApp[62357:907] (All) Number of items in playlist 16: 19
2013-02-16 20:46:09.282 MyApp[62357:907] (All) Number of items in playlist 17: 5
2013-02-16 20:46:09.283 MyApp[62357:907] (All) Number of items in playlist 18: 7
2013-02-16 20:46:09.284 MyApp[62357:907] (All) Number of items in playlist 19: 14
2013-02-16 20:46:09.284 MyApp[62357:907] (All) Number of items in playlist 20: 247
2013-02-16 20:46:09.285 MyApp[62357:907] (All) Number of items in playlist 21: 12
2013-02-16 20:46:09.286 MyApp[62357:907] (All) Number of items in playlist 22: 2
2013-02-16 20:46:09.286 MyApp[62357:907] (All) Number of items in playlist 23: 5
2013-02-16 20:46:09.287 MyApp[62357:907] (All) Number of items in playlist 24: 2
2013-02-16 20:46:09.288 MyApp[62357:907] (All) Number of items in playlist 25: 5
2013-02-16 20:46:09.288 MyApp[62357:907] (All) Number of items in playlist 26: 239
2013-02-16 20:46:09.289 MyApp[62357:907] (All) Number of items in playlist 27: 11
答案 0 :(得分:0)
似乎过滤器仅适用于查询的items
属性,但遗憾的是不适用于集合“items
。