0

I wanna setup a basic PFQuery Table View Controller. I wanna display the usernames from my User class. I've added the User class to query on, but it gives this error message: *Property 'className' not found on object of type 'InboxViewController '

I don't understand why happens this, because the user class exists, it appears in the data browser. I've tried to make a property in the .h file, but it was unsuccessful.

#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 file

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface InboxViewController : PFQueryTableViewController

- (IBAction)logout:(id)sender;

@end
2
  • Show the .h file for your InboxViewController. Does it define a property named className? Commented Apr 30, 2014 at 21:33
  • I've extended the question with the header file. @Fogmeister Yes, i did it. Commented Apr 30, 2014 at 21:41

1 Answer 1

1

OK, I just remembered.

The property you are looking for is parseClassName not className.

Change this and it should work.

Sign up to request clarification or add additional context in comments.

5 Comments

Working fine! Great! Can you tell me why parseClassName? Because i've copied the official sample code from the Github and it contains the className version.
@sabin I'm guessing either you mis-copied it or it's an old version of the code? github.com/ParsePlatform/TodoTable/blob/master/… This shows parseClassName.
I've used this gist.github.com/jamesyu/ba03c1a550f14f88f95d , it was linked from the Parse forum by a Parser. I'm getting a new error now 'linked command error' - duplicate symbol _OBJC_IVAR_$_LoginViewController._usernameTextField in:. What do you think, it's because the className was changed? I've never seen this error.
Well that gist is nothing to do with parse. It's just some guy who put some code on the web. As for your new error. Looks like you've created a userNameTextField of your own when one already exists. Possibly. No idea without seeing your code. However, go to the parse website and click on documentation. Everything you need is there. Don't rely on random code you find on the web.
I think i've really mixed up this stuffs. Thnx for the useful advices, i'll rebuild it from scratch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.