【发布时间】:2014-04-30 21:25:49
【问题描述】:
我想设置一个基本的 PFQuery 表视图控制器。我想显示我的用户类中的用户名。我添加了要查询的 User 类,但它给出了以下错误消息:*Property 'className' not found on object of type 'InboxViewController '
我不明白为什么会这样,因为用户类存在,它出现在数据浏览器中。我试图在 .h 文件中创建一个属性,但没有成功。
#import "InboxViewController.h"
#import <Parse/Parse.h>
#import "LoginViewController.m"
@interface InboxViewController ()
@end
@implementation InboxViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom the table
// The className to query on
self.className = @"User";
// The key of the PFObject to display in the label of the default cell style
self.textKey = @"username";
// 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;
}
#pragma mark - UIViewController
- (void)viewDidLoad
{
[super viewDidLoad];
PFUser *currentUser = [PFUser currentUser];
if (currentUser) {
NSLog(@"Current user: %@", currentUser.username);
} else {
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
}
.h 文件
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface InboxViewController : PFQueryTableViewController
- (IBAction)logout:(id)sender;
@end
【问题讨论】:
-
显示您的
InboxViewController的.h 文件。它是否定义了一个名为className的属性? -
我已经用头文件扩展了这个问题。 @Fogmeister 是的,我做到了。
-
@sabin 看到我的回答 :)
标签: objective-c parse-platform