Reputation: 11493
I have the following code:
NSURL* saveToURL = [[NSURL alloc] initWithString:[self.recording filePath]];
NSLog([saveToURL absoluteString]);
NSLog(@"?");
NSLog([self.recording filePath]);
which outputs the following
2013-08-07 15:51:32.182 SpyApp[49799:c07] ?
2013-08-07 15:51:32.183 SpyApp[49799:c07] /Users/Mike/Library/Application Support/iPhone Simulator/6.1/Applications/C9EDE058-5C8B-4B75-8638-D5A4265B348F/Documents/Recordings/ujaxvehvjlgwfuw
In the debugger, I can also see that saveToURL
is nil
, despite the fact that [self.recording filePath]
returns /Users/Mike/Library/Application Support/iPhone Simulator/6.1/Applications/C9EDE058-5C8B-4B75-8638-D5A4265B348F/Documents/Recordings/ujaxvehvjlgwfuw
Why is that? How do I fix it?
Upvotes: 1
Views: 159
Reputation: 70713
Because filePath is a path, not a URL. To create a file URL, use a different method:
NSURL* saveToURL = [[NSURL alloc] initFileURLWithPath:[self.recording filePath]];
On a side note, the first parameter to NSLog should always be a constant string, you never know when filePath could have a %
in it.
NSLog(@"%@", [saveToURL absoluteString]);
NSLog(@"?");
NSLog(@"%@", [self.recording filePath]);
Upvotes: 3