我想设置一个基本的PFQuery表视图控制器。我想显示User类中的用户名。我已经添加了要查询的User类,但是它给出了以下错误消息: *属性'className'找不到类型为'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
答案 0 :(得分:1)
好的,我记得。
您要查找的属性为parseClassName
而不是className
。
改变这一点,它应该有效。