Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-15-2011, 07:06 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Location: Chisinau , Republic of Moldova
Posts: 17
numismatyc is on a distinguished road
Default Wich is the best way to save text from a TEXTVIEW ???

Wich is the best way to save text from a TEXTVIEW ???

Please tell me ,cause i'm new... Thanks a lot...
numismatyc is offline   Reply With Quote
Old 02-15-2011, 07:24 AM   #2 (permalink)
Registered Member
 
wanx's Avatar
 
Join Date: Dec 2010
Posts: 74
wanx is on a distinguished road
Default

Uhm for how long do you want the data to be stored? If you need it for a longer time use a simple textfile otherwise use global variables.
wanx is offline   Reply With Quote
Old 02-22-2011, 09:53 PM   #3 (permalink)
Registered Member
 
TheFlyingDutchman's Avatar
 
Join Date: Feb 2011
Location: NYC
Posts: 81
TheFlyingDutchman is on a distinguished road
Default

I'd recommend using NSUserDefaults.


First, to get the text from a textview:

make sure to create an IBOutlet of the TextView and link it in IB.
In my case, I called it myTextView.
Code:
    NSString *returnedTextFromTextView;
    myTextView.text = returnedTextFromTextView;
    NSLog(returnedTextFromTextView);
To save the returned text:

Code:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:returnedTextFromTextView forKey:@"TextView"];
and to get it:

Code:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *myTextView = [userDefaults objectForKey:@"TextView"];
TheFlyingDutchman is offline   Reply With Quote
Old 02-22-2011, 10:57 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 284
BioBuff is on a distinguished road
Default

Quote:
Originally Posted by TheFlyingDutchman View Post
I'd recommend using NSUserDefaults.


First, to get the text from a textview:

make sure to create an IBOutlet of the TextView and link it in IB.
In my case, I called it myTextView.
Code:
    NSString *returnedTextFromTextView;
    myTextView.text = returnedTextFromTextView;
    NSLog(returnedTextFromTextView);
To save the returned text:

Code:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:returnedTextFromTextView forKey:@"TextView"];
and to get it:

Code:
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *myTextView = [userDefaults objectForKey:@"TextView"];
Thanks for posting this code!

Does this code save the text automatically as the user types? And does it save the text automatically upon termination of the app? If not, how would you recommend I do these actions.

Thanks in advance.
BioBuff is offline   Reply With Quote
Reply

Bookmarks

Tags
data, iphone, string, uitextview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 374
9 members and 365 guests
chemistry, cpsclicker, daudrizek, jeroenkeij, Kirkout, PavelMik, teebee74, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,666
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, cpsclicker
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:04 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0