Reputation: 11493
I have the following in my program:
return [directory URLByAppendingPathComponent:fileName];
checking with a debugger, fileName
is __NSCFString * @"OA1aK7ikkYq5cK5"
(so it contains @"OA1aK7ikkYq5cK5"
)
directory
is a URL retrieved with:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
Why does this throw this:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSPathStore2 URLByAppendingPathComponent:]: unrecognized selector sent to instance 0x10fa01de0
Upvotes: 0
Views: 1442
Reputation: 7341
NSSearchPathForDirectoriesInDomains
returns an array of strings, not URLs. You should be calling
NSURL *directory = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
EDIT
Just wanted to clarify that it's an array of NSPathStore2
objects, which is a subclass of NSString
.
Upvotes: 7