added done save button in naviagtion bar right . .Text i can able to see in console uisng nslog in saveAction method , but i am not getting my current folder for savedText.text file. how to check my file. Same time i need to restore my text data in my notes , please guide me
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = @"Notes";
// the nav bar's custom Done button right view
UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(saveAction

] autorelease];
self.navigationItem.rightBarButtonItem = addButton;
}
- (void)saveAction

id)sender
{
// finish typing text/dismiss the keyboard by removing it as the first responder
//
[self.textview resignFirstResponder];
//self.navigationItem.rightBarButtonItem = nil; // this will remove the "save" button
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"savedText.txt"];
NSString *savedString = textview.text;
NSLog(@"The Save file is:%@", savedString);
[savedString writeToFile:documentTXTPath atomically:YES];
}
Quote:
Originally Posted by baja_yu
Never tried to write a large string so I don't know what the downside is, if any. NSString has methods for reading from and saving to a file so that solution is trivial too.
|