I'm not sure if this is possible, but I hope it is and I need some help doing it if so.
I have a mainView in which I have an NSMutableDictionary.
In that Dictionary is a key (identity) which gives the name for the text entered in one textField.
Another key (number key) gives the name for the text entered in a second textField
After these two fields are entered a button bar is clicked and the keyboard disappears and the .txt files are stored in the Documents Directory.
another key (photoKey) in the Dictionary sets the path and gives the name for a photo the user takes with the camera.
What I wish to do is have the text entered into the second textfield be the name for the photo given in the key (photoKey).
So lets say the user enters the number 1 into the (numberkey) textfield. I then want the name of the photo in the (photoKey) to be 1.jpg.
Is this possible?
Here is my code;
MainView handing off the NSMutableDictionary;
In my DetailViewController I use this to take the picture;
Any Ideas will be greatly appreciated!
I have a mainView in which I have an NSMutableDictionary.
In that Dictionary is a key (identity) which gives the name for the text entered in one textField.
Another key (number key) gives the name for the text entered in a second textField
After these two fields are entered a button bar is clicked and the keyboard disappears and the .txt files are stored in the Documents Directory.
another key (photoKey) in the Dictionary sets the path and gives the name for a photo the user takes with the camera.
What I wish to do is have the text entered into the second textfield be the name for the photo given in the key (photoKey).
So lets say the user enters the number 1 into the (numberkey) textfield. I then want the name of the photo in the (photoKey) to be 1.jpg.
Is this possible?
Here is my code;
MainView handing off the NSMutableDictionary;
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
const NSDictionary *const row = [self rowForIndexPath:indexPath];
NSString *wantedClassName = [row objectForKey:@"controller"];
UIViewController *const vc = [[NSClassFromString (wantedClassName) alloc] init];
NSLog(@"controller is -%@-", wantedClassName);
if ([vc isKindOfClass:[DetailViewController class]])
{
DetailViewController*lcVC =(DetailViewController*)vc;
NSMutableDictionary *myDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
//I have tried this but it isn't working, it only names the photo (image name.txt).jpg
@"Documents/(imagename.txt).jpg",@"photokey",
@"name.txt", @"identity",
@"imagename.txt",@"numberkey",nil];
lcVC.myDictionary = myDictionary;
NSLog(@"photokey");//I know this isn't correct, how would I get the exact name of the photo from this?
}
[self.navigationController pushViewController:vc animated:YES];
In my DetailViewController I use this to take the picture;
Code:
-(IBAction)getPhoto:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera ;
[self presentModalViewController: picker animated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
[picker dismissModalViewControllerAnimated:YES];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:[(NSMutableDictionary *)myDictionary objectForKey:@"photokey"]];
// Access the uncropped image from info dictionary
NSError *error;
[UIImageJPEGRepresentation(image, 0.5) writeToFile:jpgPath atomically:YES];
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
}
Any Ideas will be greatly appreciated!
Last edited: