PFObject值可能没有类:PFFile

时间:2015-01-27 11:30:07

标签: ios objective-c parse-platform

我收到此错误" PFObject值可能没有类:PFFile"当我尝试在Parse对象上保存图像时......

这是代码和对象:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"GGB" ofType:@"jpg"];
    NSData *d = [NSData dataWithContentsOfFile:path];
    PFFile *f = [PFFile fileWithName:[NSString stringWithFormat:@"f_%d_%d.jpg",ctIdx,chIdx] data:d];

    GPChallenge *ch = GPChallenge.object;
    ch.name = [NSString stringWithFormat:@"Challenge %d.%d",(chIdx+1),(ctIdx+1)];
    ch.category = cat;
    ch.image = f;

    [f save];
    [ch save];

- GPChallenge.h

#import <Parse/Parse.h>

@class GPCategory;

@interface GPChallenge : PFObject<PFSubclassing>
+ (NSString *)parseClassName;

@property NSString *name;
@property GPCategory *category;
@property PFFile *image;
@end

- GPChallenge.m

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

@implementation GPChallenge

@dynamic name;
@dynamic category;
@dynamic image;

+(void)load {
    [self registerSubclass];
}

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

@end

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我猜你是从你的app目标中调用[Parse setApplicationId:clientKey:]。 您是否尝试过单元测试方法?

Class MainAppPFFile = [[NSBundle mainBundle]classNamed:@"PFFile"];
PFFile *f = [MainAppPFFile fileWithName:[NSString stringWithFormat:@"f_%d_%d.jpg",ctIdx,chIdx]