Hey,
in my app I want to save the text that was typed in in a UITextView. How can I do this?
Thanks for you help.
Leon
Hey,
in my app I want to save the text that was typed in in a UITextView. How can I do this?
Thanks for you help.
Leon
NSString *theText = myTextView.text;
Thats how to get the text from it. You can save it in a variety of places, but where do you want to save it? The user defaults? Core Data? A plaintext file? A properties file? An xml file? In a web app?
Create a dictionary and add your text with the key to the dictionary
NSDictionary *dict = [[NSMutableDictionary alloc] init];
NSString *str = myTextView.text;
[dict setObject:str forKey:@"theText"];
Register your dictionary to NSUserDefaults
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
[[NSUserDefaults standardUserDefaults] synchronize];
[dict release];
Retrieving it in your whole app:
NSString *theText = [[NSUserDefaults standardUserDefaults] stringForKey:@"theText"];