Wesley Cho
Wesley Cho

Reputation: 495

PFObject subclass isn't creating new class in parse dashboard

I created a PFObject subclass like so:

Question.h

#import <Parse/Parse.h>
#import "InterestLevelIcon.h"

@class User, Question;

@interface Question : PFObject <PFSubclassing>

+(NSString *)parseClassName;

@property (retain, nonatomic) User *user;
@property (retain, nonatomic) NSString *questionText;

@end

Question.m

#import <Parse/PFObject+Subclass.h>
#import "Question.h"
#import "User.h"

@implementation Question

@dynamic user;
@dynamic questionText;

+(NSString *)parseClassName {
    return @"Question";
}

@end

And now I'm trying to create a test Question here:

QuestionCreationTest.m

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "Question.h"

@interface QuestionCreationTest : XCTestCase

@end

@implementation QuestionCreationTest

- (void)setUp {
    [super setUp];
}

- (void)tearDown {
    [super tearDown];
}

- (void)questionCreationTest {
    Question *question = [Question object];
    question.questionText = @"I am a cute bunny";

    [question save];

}

@end

Nothing comes up in my Parse dashboard though. The only class that I have in it is my subclassed PFUser which is working fine. Also when I try to run my app I get this error

[Error]: bad characters in classname: (null) (Code: 103, Version: 1.7.5)

I think it's because my TableViewController is trying to "initWithCoder" with a Question class that's not there yet which is the reason why I'm trying to create the first question.

(Yes I did register the class in the AppDelegate) [Question registerSubclass]

Here are my questions:

1) Why isn't my test creating a new "Question" class in my Parse dashboard?

2) Why isn't the Question class created at all?

3) Should I manually create a new class in my Parse dashboard and try to link it to my Question subclass?

4) Should I initialize the properties in Question to default values? Would the new class show up in the my Dashboard then?

Upvotes: 0

Views: 94

Answers (1)

mKane
mKane

Reputation: 982

You need to say

Question *question = [Question objectWithClassName@"YOURCLASSNAME"];

Upvotes: 1

Related Questions