jeudi 8 janvier 2015

Inserting imagestring data into my database

I want to add the data which I have in string format into my database. Also is the conversion that i made from image to string correct. I use my picker to pick an image from the library, and then convert it to string , now how do I save it.



- (IBAction)buttonTapped:(id)sender {
_picker = [[UIImagePickerController alloc] init];
_picker.delegate = self;
_picker.allowsEditing = NO;
_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:_picker animated:YES completion:nil];
}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[_images addObject:image];
[self saveNewImageToDb:image];
NSData *imageData = UIImagePNGRepresentation(image);
NSString *imageString = [[NSString alloc] initWithBytes: [imageData bytes] length:[imageData length] encoding:NSUTF8StringEncoding];



// 1: call conversion
// 2: make Query wat in NSString in gaan INSERT (PHP) FAKE title and desc

[self dismissViewControllerAnimated:_picker completion:^{
[_collectionView reloadData];
}];

}


-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:_picker completion:nil];
}

Aucun commentaire:

Enregistrer un commentaire