Created
January 3, 2016 14:13
-
-
Save tranhieutt/92ec3b2cca0f7958e093 to your computer and use it in GitHub Desktop.
Add object into class in Parse.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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