Created
April 15, 2010 08:14
-
-
Save minase/366832 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// ImagePicker で選択された画像を保存する | |
// | |
// | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info | |
{ | |
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; | |
// 画像を保存(バンドルのルートディレクトリ) | |
NSData *jpeg = [[NSData alloc] initWithData:UIImageJPEGRepresentation(image, 100)]; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *docDir = [paths objectAtIndex:0]; | |
NSString *fileName = [docDir stringByAppendingPathComponent:@"oppai.jpg"]; | |
NSLog(@"save; %@", fileName); | |
if ([jpeg writeToFile:fileName atomically:YES] == NO) { | |
NSLog(@"fail!!!!!!!"); | |
} else { | |
NSLog(@"oppai!!"); | |
} | |
// ログ | |
NSFileManager *fm = [NSFileManager defaultManager]; | |
NSArray *files = [fm contentsOfDirectoryAtPath:docDir error:nil]; | |
NSLog(@"%@", files); | |
[jpeg release]; | |
[self dismissModalViewControllerAnimated:YES]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment