我试图让PFUser
能够编辑他们创建的PFObject
值。
目前,PFUser
在PFOBject
类中创建ClientCreater
:
-(IBAction)New:(id)sender
{
PFObject *New = [PFObject objectWithClassName:@"client"];
PFUser *user = [PFUser currentUser];
[New setObject:user.username forKey:@"username"];
[New setObject:[[self Name] text] forKey:@"name"];
[New setObject:[[self Team] text] forKey:@"team"];
[New setObject:[[self Points] text] forKey:@"points"];
[New setObject:[[self Height] text] forKey:@"height"];
[New setObject:[[self Weight] text] forKey:@"weight"];
[New setObject:[[self Position] text] forKey:@"position"];
[New setObject:[[self Game] text] forKey:@"game"];
[New setObject:[[self Hometown] text] forKey:@"hometown"];
[New setObject:[[self Birthday] text] forKey:@"birthday"];
// [New setObject:[[self Bio] text] forKey:@"bio"];
NSData *imageData = UIImageJPEGRepresentation(PlayerImage.image, 0.8);
NSString *filename = [NSString stringWithFormat:@"%@.png", Name.text];
PFFile *imageFile = [PFFile fileWithName:filename data:imageData];
[New setObject:imageFile forKey:@"imageFile"];
[New saveInBackground];
NSLog(@"Object Added");
}
这是我尝试检索PFObject
类的viewDidLoad
中的ClientEditController
:
PFQuery *query = [PFQuery queryWithClassName:@"client"];
// BEFORE WE QUERY
[query whereKey:@"user" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// Get your objects here
[objectt objectForKey:@"user"];
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
在.h我宣布了这个:
@property(nonatomic, strong) PFObject *objectt;
然后我在这里尝试为name
更新PFUser
的值:
-(IBAction)SaveObject:(id)sender
{
[objectt setObject:Name.text forKey:@"name"];
[objectt saveInBackground];
}