【问题标题】:PFQueryTableViewController Class Query ErrorPFQueryTableViewController 类查询错误
【发布时间】: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


【解决方案1】:

好的,我想起来了。

您要查找的属性是parseClassName 而不是className

改变它,它应该可以工作。

【讨论】:

  • 工作正常!伟大的!你能告诉我为什么 parseClassName 吗?因为我从 Github 复制了官方的示例代码,它包含了 className 版本。
  • @sabin 我猜你是复制错了还是旧版本的代码? github.com/ParsePlatform/TodoTable/blob/master/… 这显示parseClassName
  • 我用过这个 gist.github.com/jamesyu/ba03c1a550f14f88f95d ,它是由解析器从 Parse 论坛链接的。我现在收到一个新错误“链接命令错误” - 重复符号 _OBJC_IVAR_$_LoginViewController._usernameTextField in:。你怎么看,这是因为 className 被改变了?我从未见过这个错误。
  • 嗯,这个要点与解析无关。只是一些人在网上放了一些代码。至于你的新错误。看起来您已经创建了一个自己的 userNameTextField,但它已经存在。可能。没有看到你的代码不知道。但是,请转到解析网站并单击文档。你需要的一切都在那里。不要依赖您在网络上找到的随机代码。
  • 我想我真的把这些东西弄混了。感谢您提供有用的建议,我将从头开始重建它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多