在我的项目中,用户提交了一个故事,我试图把它放在"流行页面"上最受关注的位置,但没有找到方法。这是我到目前为止的代码,提前感谢,是的,我知道它不多,但有什么帮助。
MasterViewContoller.m
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Customize the table
// The className to query on
self.className = @"Word";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"by";
// Uncomment the following line to specify the key of a PFFile on the PFObject to display in the imageView of the default cell style
// self.imageKey = @"image";
// Whether the built-in pull-to-refresh is enabled
self.pullToRefreshEnabled = YES;
// Whether the built-in pagination is enabled
self.paginationEnabled = YES;
// The number of objects to show per page
self.objectsPerPage = 25;
}
return self;
}
云代码
Parse.Cloud.beforeSave("Word", function(request, response) {
var wordText = request.Object.get("wordText");
var attribution = request.Object.get("by");
if(wordText.length){
if (attribution.length){
response.success();
}else{
request.object.set("by", "annoymous");
response.success();
}
}else{
response.error("Not valid. Please fill in all text");
}
});
您可以尝试在"Word"对象中创建另一个int类型的键(例如,我们称之为timesViewed
),这样,每当不是currentUser
的PFUser
查看该对象时,timesViewed
就会增加一。然后用[query orderByDescending:@"timesViewed]
查询timesViewed
。