Reputation: 157
I save the text message into plist but I don't know how to retrieve it from plist. How can one retrieve a text message in UITextView using plist?
Upvotes: 0
Views: 1054
Reputation: 1084
You might have saved your data in to the p-list file in the form of NSData, NSDate, NSNumber, NSString, NSArray, or NSDictionary,all of these classes defines a method to init them selfs with contents of a file as :initWithContentsOfFile:
.You should specify the path where you saved the p-list file as parameter to this method.You can save and retrieve string objects directly in the same manner.after initializing the string object(say stringFromPlist) with file contents write the following code to display the text:
yourTextView.text=stringFromPlist;
You may also want to see p-list programming guide
Upvotes: 1
Reputation: 3960
@Try doing this and you will get the data in you UItextView
and you have give the text data type as NSString
in your plist.
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"plistname" ofType:@"plist"];
BOOL success = [fileManager fileExistsAtPath:filePath];
if(!success){
NSLog(@"not success");
}
NSString *data = [[NSString alloc] initWithContentsOfFile:filePath];
[self.TextView setText:data];
[self.TextView setFont:[UIFont fontWithName:@"Helvetica" size:16.0]];
[data release];
Hope it will help you! Good Luck!
Upvotes: 1