-1
我更新解析和IOS,我試圖顯示視頻和照片在我的時間表。我正在擴展一個PFQueryTableViewController,並在queryForTable中嘗試定義一個查詢來提取當前用戶關注的用戶發佈的所有照片和視頻,或者由當前用戶自己發佈的帖子。我有查詢的麻煩,但這裏是我想做的事:IOS分析查詢幫助兩個類照片和視頻
parseClassName被設爲照片類:
// self.parseClassName = @"Photo";
然後在queryForTable:
- (PFQuery *)queryForTable {
if (![PFUser currentUser]) {
PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
[query setLimit:100];
return query;
}
PFQuery *followingActivitiesQuery = [PFQuery queryWithClassName:kFTActivityClassKey];
[followingActivitiesQuery whereKey:kFTActivityTypeKey equalTo:kFTActivityTypeFollow];
[followingActivitiesQuery whereKey:kFTActivityFromUserKey equalTo:[PFUser currentUser]];
followingActivitiesQuery.cachePolicy = kPFCachePolicyNetworkOnly;
followingActivitiesQuery.limit = 100;
PFQuery *photosFromFollowedUsersQuery = [PFQuery queryWithClassName:self.parseClassName];
[photosFromFollowedUsersQuery whereKey:kFTPhotoUserKey matchesKey:kFTActivityToUserKey inQuery:followingActivitiesQuery];
[photosFromFollowedUsersQuery whereKeyExists:kFTPhotoPictureKey];
/* Load videos from followed users
PFQuery *videosFromFollowedUsersQuery = [PFQuery queryWithClassName:self.parseClassName];
[videosFromFollowedUsersQuery whereKey:kFTVideoUserKey matchesKey:kFTActivityToUserKey inQuery:followingActivitiesQuery];
[videosFromFollowedUsersQuery whereKeyExists:kFTVideoKey];
*/
PFQuery *photosFromCurrentUserQuery = [PFQuery queryWithClassName:self.parseClassName];
[photosFromCurrentUserQuery whereKey:kFTPhotoUserKey equalTo:[PFUser currentUser]];
[photosFromCurrentUserQuery whereKeyExists:kFTPhotoPictureKey];
/* Load current users videos
PFQuery *videosFromCurrentUserQuery = [PFQuery queryWithClassName:self.parseClassName];
[videosFromCurrentUserQuery whereKey:kFTVideoUserKey equalTo:[PFUser currentUser]];
[videosFromCurrentUserQuery whereKeyExists:kFTVideoKey];
*/
PFQuery *query = [PFQuery orQueryWithSubqueries:[NSArray arrayWithObjects:photosFromFollowedUsersQuery, /*videosFromFollowedUsersQuery,*/
photosFromCurrentUserQuery, /*videosFromCurrentUserQuery,*/ nil]];
[query includeKey:kFTPhotoUserKey];
/*[query includeKey:kFTVideoUserKey];*/
[query orderByDescending:@"createdAt"];
// A pull-to-refresh should always trigger a network request.
[query setCachePolicy:kPFCachePolicyNetworkOnly];
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
//
// If there is no network connection, we will hit the cache first.
if (self.objects.count == 0 || ![[UIApplication sharedApplication].delegate performSelector:@selector(isParseReachable)]) {
[query setCachePolicy:kPFCachePolicyCacheThenNetwork];
}
return query;
}
此代碼可以在解析非典型例子中找到。
任何幫助表示讚賞!