Iphone 如何制作;“最受欢迎”;使用解析iOS
在我的项目中,用户提交了一个故事,我试图将其放在一个“流行页面”上,但没有找到一种方法。这是我到目前为止的代码,提前谢谢,是的,我知道它不多,但有任何帮助 MasterViewController.mIphone 如何制作;“最受欢迎”;使用解析iOS,iphone,ios,parsing,backend,Iphone,Ios,Parsing,Backend,在我的项目中,用户提交了一个故事,我试图将其放在一个“流行页面”上,但没有找到一种方法。这是我到目前为止的代码,提前谢谢,是的,我知道它不多,但有任何帮助 MasterViewController.m -(id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) { // Customize the table // The cl
-(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类型的键(例如,我们称之为,
timesweed
),这样每次PFUser
查看对象时,timesweed
都会增加一个键。然后使用[queryorderbydescending:@“timesweed]
在云代码中查询timesweed
,您应该添加timesweed对象。因此,假设创建新的“Word”类对象的代码如下所示:PFObject*Word=[PFObject objectWithClassName:@“Word”];
[Word setObject:[PFUser currentUser]forKey:@“by”];
//设置为0作为初始值``[word setObject:0 forKey:@“TimesView”]
您还可以直接从分析数据浏览器编辑您以前创建的类对象。如果数据库中存在timeswiew
对象,则只需输入0,如果不存在,则创建新行,命名并输入值。要测试它,您可以通过数据浏览器输入不同的值。没问题,谢谢。Im stil我不知道timesViewed将如何从NewPostedPage中提取,我将如何做,以及timesViewed将如何发送到其他设备。我将发布我在云代码中的内容