The problem is removing an item that´s been written using writeToFile:
method, I cannot seem to remove it. I tried NSFileManager but I guess these are two different
And the "for some reason": your "URL" is just a path, it's not a valid filesystem URL. For that, you would need to prepend file://
before the actual path, or even better, use [NSURL fileURLWithPath:]
.
In this place
result = [fileManager removeItemAtURL:destinationURL error:&removeError];
NSLog(@"ERROR REMOVING OBJECT: %@",removeError);
you log and do not check the result value. Is it really NO
? You should check return value first, and then if it is NO
, check the removeError
.
And also I prefer to write
NSError * removeError = nil;
when declarate it. May be removeError
object contains some old information.
If your file is present at that path you can try this:
[[NSFileManager defaultManager] removeItemAtPath:[destinationURL path] error:&error];
Hope this helps.