|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Is this possible? UIImage > NSData > NSString > .txt file
I'm Exporting data to a text file and I'm wondering if anyone has done this.
Convert UIImage to NSData, represent the NSdata as nsstring, and then write the the string to the textfile. Then when reading the file back in its able to reverse that back into an image. I could be misinterpreting how nsdata works but has anyone ever done this?
__________________
13" Macbook White, 2.00 ghz, 4 gig mem, 120g hd. iphone 3g - 8gig. Time Capsule 500g. iFlashCardPro - Flash Cards
|
|
|
|
0
|
|
|
#2 |
|
It's certainly possible, but seems like overkill depending on what you're trying to achieve.
If you just want to cache images then why not just convert the UIImage to NSData and write it to NSUserDefaults? Code:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSData *data = UIImagePNGRepresentation(image); [defaults setObject:data forKey:@"key"]; Code:
NSData *data = [defaults dataForKey:@"key"]; UIImage *image = [UIImage imageWithData:data]; For converting NSString and NSData back and forth, you can use: Code:
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; Code:
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; Last edited by jnic; Apr 21, 2010 at 10:12 AM. |
|
|
|
0
|
|
|
#3 |
|
Yeah, why the need to convert to string?
__________________
|
|
|
|
0
|
|
|
#4 |
|
Thanks for confirming it
![]() Well in my application I'm enabling the user to export their decks of cards to google docs which is stored as Google Doc. Each card consists of question, answer, image, audio. so I'm building the file that would be able to be imported from Google docs. So I think i would need to make it a string to be able to add it to the file properly, (well the current way I am doing it.). I'm not actually storing anything in the text file for the app storage this is all done in a sqlite database, this is just for exporting to Google Docs. thanks for the responses!
__________________
13" Macbook White, 2.00 ghz, 4 gig mem, 120g hd. iphone 3g - 8gig. Time Capsule 500g. iFlashCardPro - Flash Cards
|
|
|
|
0
|
|
|
#5 |
|
From your NSData, I'd look at converting it using uuencode and decoding with uudecode. The other option is Base 64. This is common with e-mail applications.
|
|
|
|
0
|
|
|
#6 | |
|
Quote:
Thanks in advance, Fran |
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| What does this mean and how is this possible | waloshin | Apple, Industry and Internet Discussion | 5 | Aug 19, 2011 09:16 AM |
| how is this possible? (printing to pdf file from windows-parallels) | phuong | Windows, Linux & Others on the Mac | 14 | Jun 29, 2011 04:42 PM |
| Is this possible that automator to unrar many files? | hndn | Mac Basics and Help | 2 | Mar 14, 2010 03:52 AM |
| How is this possibly being sold at this price?! | andalusia | MacBook Pro | 16 | Oct 29, 2009 08:11 AM |
| Is this possible? If so, is it legal? | BrownPlopz | Windows, Linux & Others on the Mac | 4 | Mar 30, 2008 06:29 PM |
All times are GMT -5. The time now is 02:59 AM.




13" Macbook White, 2.00 ghz, 4 gig mem, 120g hd.



Linear Mode

