The problem would appear to be in your fileExistsAtPath
line. You appear to be saying "if the documents directory doesn't exist, then create the file". That's certainly not right.
Personally, I'd lose that stuff and change it to be
- (NSURL *)exportToCSV
{
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *filePath = [docPath stringByAppendingPathComponent:@"results.csv"];
NSMutableString *contents = [NSMutableString stringWithCapacity:0];
//fill contents with data in csv format
// ...
NSError *error;
[contents writeToFile:filePath
atomically:YES
encoding:NSUTF8StringEncoding
error:&error];
// check for the error
return [NSURL fileURLWithPath:filePath];
}