I have this code below:
NSString *fileName = [[NSUserDefaults standardUserDefaults] objectForKey:@"recentDownload"];
NSString *fullPath = [NSBundle pathForResource:fileName ofType:@"txt" inDirectory:[NSHomeDirectory() stringByAppendingString:@"/Documents/"]];
NSError *error = nil;
[textViewerDownload setText:[NSString stringWithContentsOfFile:fullPath encoding: NSUTF8StringEncoding error:&error]];
textviewerdownload
is thetextview
displaying the text from the file. The actual file name is stored in anNSUserDefault
calledrecentDownload
.When I build this, I click the
button
which this is under, and my applicationcrashes
.Is there anything wrong with the syntax or just simple error?