Preliminary notes:
I am using Xcode 4.2.1
I am working with IOS 5 SDK
I have enables ARC
I am using storyboard
I had no warning in my code
I am running the following in the iPhone simulator
The csv file that is generated can be found within the finder, and stores data correctly
These methods are implemented in the controller of the view containing the buttons and text inputs (as seen in pic)
The results won't show in the results text field.
I'm confident all of my connections are set up correctly, and I have the properties set as public.
I am using Xcode 4.2.1
I am working with IOS 5 SDK
I have enables ARC
I am using storyboard
I had no warning in my code
I am running the following in the iPhone simulator
The csv file that is generated can be found within the finder, and stores data correctly
These methods are implemented in the controller of the view containing the buttons and text inputs (as seen in pic)

Code:
- (IBAction)storeResults:(id)sender {
NSString *csvLine = [NSString stringWithFormat:@"%@,%@,%@\n",
self.firstName.text,
self.lastName.text,
self.email.text];
NSString *docDir = [NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask, YES)
objectAtIndex:0];
NSString *surveyFile = [docDir stringByAppendingPathComponent:@"surveyresults.csv"];
if (![[NSFileManager defaultManager] fileExistsAtPath:surveyFile]) {
[[NSFileManager defaultManager] createFileAtPath:surveyFile contents:nil attributes:nil];
}
NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:surveyFile];
[fileHandle seekToEndOfFile];
[fileHandle writeData:[csvLine dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandle closeFile];
self.firstName.text = @"";
self.lastName.text =@"";
self.email.text = @"";
}
Code:
- (IBAction)showResults:(id)sender {
NSString *docDir = [NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask, YES)
objectAtIndex:0];
NSString *surveyFile = [docDir stringByAppendingPathComponent:@"surveyresults.csv"];
if (![[NSFileManager defaultManager] fileExistsAtPath:surveyFile]) {
NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:surveyFile];
NSString *surveyResults = [[NSString alloc] initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
[fileHandle closeFile];
self.resultsView.text = surveyResults;
}
}
The results won't show in the results text field.
I'm confident all of my connections are set up correctly, and I have the properties set as public.
Last edited: