Covert uiiamge into string

Posted by Warrior on Stack Overflow See other posts from Stack Overflow or by Warrior
Published on 2010-03-24T11:40:40Z Indexed on 2010/03/24 11:43 UTC
Read the original article Hit count: 316

Filed under:
|
|
|

I am new iphone development.Is there any possibility to covert the uiimage into string and then once again back to image.

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img1 editingInfo:(NSDictionary *)editInfo {

[[picker parentViewController] dismissModalViewControllerAnimated:YES];
NSData *data = UIImagePNGRepresentation(img1);

NSString *str1;
str1 = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *) [[UIApplication sharedApplication] delegate];
[appDelegate setCurrentLink:str1]; 

EmailPictureViewController *email = [[EmailPictureViewController alloc] initWithNibName:@"EmailPictureViewController" bundle:nil];

[self.navigationController pushViewController:email animated:YES];
    }

so i can use delegate methods to tranfer the image from one view to another view. so i should convert the string once again to image and display it in another view.

In Another view

  - (void)viewDidLoad {
MyAppAppDelegate *appDelegate =(MyAppAppDelegate *) [[UIApplication sharedApplication] delegate]; 
str1 = [appDelegate getCurrentLink];
NSLog(@"The String %@",str1);

NSData *aData;
aData = [str1 dataUsingEncoding: NSASCIIStringEncoding];
NSLog(@"The String Data %@",aData);
NSLog(@"Inside Didload3");
[imgview setImage:[UIImage imageWithData:aData]];

 }

But this doesn't work for me.Where do i go wrong.Is there any way to solve it?.Please help me out.Thanks.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiimage