您好,我在从 Parse LocalDataStore 检索 PFObject 子类时遇到问题,我在固定之前已经 NSLogged 对象,它看起来很好,它也成功固定。但是当我在固定对象后去查询对象时,什么都没有出现。
下面是我的代码。有人可以帮我找回我的物品吗?
提前致谢。
Job.h
@interface Job : PFObject<PFSubclassing>
/* Set up all properties that we'll need to record jobs */
// Job Details Properties
@property (retain) NSString *name;
@property (retain) NSString *identifier;
@property (retain) NSString *contact;
@property (retain) NSString *address;
@property (retain) NSString *postcode;
+ (NSString *)parseClassName;
@end
----
Job.m
#import "Job.h"
#import <Parse/Parse.h>
#import <Parse/PFObject+Subclass.h>
@implementation Job
@dynamic name;
@dynamic identifier;
@dynamic contact;
@dynamic address;
@dynamic postcode;
+ (NSString *)parseClassName {
return @"Jobs";
}
@end
----
MyJobsController.m
#import "MyJobsController.h"
#import "Job.h"
@implementation MyJobsController
- (IBAction)addJob:(id)sender {
Job *jobOne = [[Job alloc] init];
jobOne.name = @"Company 001";
jobOne.contact = @"Dave";
jobOne.identifier = @"001";
[jobOne pinInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if (succeeded) {
NSLog(@"Pinned job: %@",job);
[self getJobs];
}else{
NSLog(@"Error: %@",error.userInfo);
}
}];
}
- (void)getJobs {
PFQuery *query = [Job query];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"Found Jobs: %@",objects);
}else{
NSLog(@"Error: %@",error.userinfo);
}
}];
}
----
MyJobsController.h
#import <UIKit/UIKit.h>
@interface MyJobsController : UIViewController
- (IBAction)addJob:(id)sender;
@end