Search code examples
objective-cnsurl

URLWithString removes part of NSString path


I'm having trouble parsing a csv file with CHCSVParser. My csv file doesn't "satisfy the stream" I and think the problem is that the URL for the file is bad. I get the URL like this:

NSString *path = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"csv"]];
NSURL *url = [NSURL URLWithString:path];

When I log path I get this string:

/Users/wilhelmmichaelsen/Library/Developer/CoreSimulator/Devices/11F0BE77-9179-4A7B-B03E-1143957A8D02/data/Containers/Bundle/Application/7FE0AD10-DE7A-4C6D-9EED-4A95F9C197AE/Climate.app/file.csv

When I log url I get this string:

/Users/wilhelmmichaelsen/Library/Developer/CoreSimulator/Devices/11F0BE77-9179-4A7B-B03E-1143957A8D02/data/Containers/Bu ... le.csv

It seems like the path string is being shortened (...). Is this something strange and how can I fix it?


Solution

  • You should use fileURLWithPath to create a URL from a path.