-1

在我的项目中,用户提交了一个故事,我试图将这个故事放在“热门页面”上,但还没有找到方法。到目前为止,这是我的代码,提前致谢,是的,我知道它不多,但有任何帮助。

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");
}

});
4

1 回答 1

1

您可以尝试使用 int 类型在“Word”对象中创建另一个键(例如,让我们称之为,timesViewed),以便每次PFUser不是currentUser对象视图的atimesViewed增加一个。然后查询timesViewedwith [query orderByDescending:@"timesViewed]

于 2013-07-07T23:56:22.500 回答