由于它没有在文档或在线任何地方说,如何在自定义类中设置对象?例如,您创建一个名为Friends的自定义类,它有三列:user(字符串),added(关系),friends(关系)。例如,如何在应用中设置用户?
答案 0 :(得分:4)
PFObject子类化在文档中: https://www.parse.com/docs/ios_guide#subclasses/iOS
您需要:
parse.com的自定义子类示例,其中“Organization”为Parse类名:
<强> Organization.h 强>
has_many :orders
<强> Organization.m 强>
//
// Organization.h
#import <Parse/Parse.h>
@interface Organization : PFObject<PFSubclassing>
+ (NSString *)parseClassName;
@property (retain) NSString *user;
@property (retain) NSString *addressLine1;
@property (retain) NSString *addressState;
@property (retain) NSString *addressZip;
@property (retain) NSString *phone;
@property (retain) NSString *email;
@property (retain) NSString *website;
@property (retain) NSString *contactFirstName;
@property (retain) NSString *contactLastName;
@property (retain) PFFile *logoImage;
@property (retain) NSString *orgDescription;
@property (retain) NSString *name;
@end
@end
如何在AppDelegate中初始化
#import "Organization.h"
#import <Parse/PFObject+Subclass.h>
@implementation Organization
@dynamic addressCity;
@dynamic addressLine1;
@dynamic addressState;
@dynamic addressZip;
@dynamic phone;
@dynamic email;
@dynamic website;
@dynamic contactFirstName;
@dynamic contactLastName;
@dynamic logoImage;
@dynamic orgDescription;
@dynamic name;
+ (NSString *)parseClassName {
return @"Organization";
}