Skip to content

Instantly share code, notes, and snippets.

@tranhieutt
Created January 3, 2016 14:13
Show Gist options
  • Save tranhieutt/92ec3b2cca0f7958e093 to your computer and use it in GitHub Desktop.
Save tranhieutt/92ec3b2cca0f7958e093 to your computer and use it in GitHub Desktop.
Add object into class in Parse.com
-(void)addAccessory:(HondaDataItem *)hondaDataItem withCompletion:(void(^)(BOOL success))completion failure:(void(^)(HondaFailureCode failureCode))failure{
PFObject *hondaItem = [PFObject objectWithClassName:@"HondaItem"];
hondaItem[@"groupAccessary"] = @"Điện";
hondaItem[@"nameItem"] = @"Đèn chiếu hậu sau";
hondaItem[@"description"] = @"Bổ xung";
hondaItem[@"renewPrice"] = @50000;
hondaItem[@"fixedPrice"] = @10000;
hondaItem[@"startDate"] = [NSDate date];
hondaItem[@"endDate"] = [NSDate date];
// Convert to JPEG with 50% quality
// NSData* data = UIImageJPEGRepresentation(imageView.image, 0.5f);
UIImage *image = [UIImage imageNamed:@"star_64_blue.png"];
NSData *data = UIImageJPEGRepresentation(image,1);
PFFile *imageFile = [PFFile fileWithName:@"denchieuhau.jpg" data:data];
hondaItem[@"imageFile"] = imageFile;
[hondaItem saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
// The object has been saved.
completion(succeeded);
} else {
// There was a problem, check error.description
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment