I’ve an NSOpenPanel called oPanel. From it, I get the path of a folder. As I use URLs (instead of the deprecated filenames) I want to get rid of the beginning (file://localhost).
But I have the following error that I can’t understand:
2011-07-29 18:01:45.587 RedimV3[12857:407] -[NSURL length]: unrecognized selector sent to instance 0x1023543d0
2011-07-29 18:01:45.588 RedimV3[12857:407] -[NSURL length]: unrecognized selector sent to instance 0x1023543d0
Here is the code:
NSArray *files = [oPanel URLs];
NSLog(@"before: %@", [files objectAtIndex:0]);
NSMutableString *temp = [[NSMutableString alloc] initWithString:[files objectAtIndex:0]];
[temp deleteCharactersInRange:NSMakeRange(0,15)];
NSLog(@"after: %@",temp);
The first NSLog works, the second doesn’t.
I will be glad if you can help me, thanks.
[files objectAtIndex:0]is probably an NSURL, not an NSString. Try using[[files objectAtIndex:0] path]instead. In fact, if you use-pathyou won’t even have to worry about thefile://part.