Hi.
I am implementing the Open Recent Menu in a not NSDocument app.
After getting the url of the file throught NSOpenPanel whith the full path to the file, the app proceds to open the file and peocces it, in succes, the app cals:
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:self.URLFile];
this adds the file to Open Recent Menu, at this point all ok.
When I try to open the file throught Open Recent Menu, the app cals:
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
returning YES if the file is sucesfully open, at this point all ok Works fine.... BUT only works if the app is running into XCode, if archive the app export an launch in Finder, not works. Simple this last method is neveer called.
A thinkg at I ma missing somethig... any help to make this works outside Xcode will be apreciated.
Manuel.
Edit:
After loogin the app inside XCode as in Terminal App, the problem is when I try to convert from NSString to NSURL. this is the code:
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
// paths in NSDocumentController recentDocumentURLs array
NSLog(@"Paths in recentDocumentURLs");
for (NSURL *url in [NSDocumentController sharedDocumentController].recentDocumentURLs) {
NSLog(@"Path: %@",[url absoluteString]);
}
NSLog(@"Path filename: %@", filename);
NSString *temp = [filename stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Path temp: %@", temp);
self.archivoURL = [NSURL fileURLWithPath:filename isDirectory:NO];
NSLog(@"Path self.archivoURL: %@", self.archivoURL);
if (self.archivoURL == nil) return NO;
// open file...
return YES;
} // Fin de application:OpenFile
this code inside XCode logs:
Paths in recentDocumentURLs
2016-12-21 00:08:23.118577 AppMake[9424:253018] Path: file:///Users/Manuel/Documents/Modelos%203D/X_single_Ring_round_40.stl
2016-12-21 00:08:23.118612 AppMake[9424:253018] Path: file:///Users/Manuel/Documents/Modelos%203D/pirinola.stl
2016-12-21 00:08:23.118625 AppMake[9424:253018] Path: file:///Users/Manuel/Documents/Modelos%203D/cubo%203.stl
2016-12-21 00:08:23.118636 AppMake[9424:253018] Path filename: /Users/Manuel/Documents/Modelos 3D/cubo 3.stl
2016-12-21 00:08:23.118665 AppMake[9424:253018] Path temp: /Users/Manuel/Documents/Modelos%203D/cubo%203.stl
2016-12-21 00:08:23.118706 AppMake[9424:253018] Path self.archivoURL: file:///Users/Manuel/Documents/Modelos%203D/cubo%203.stl
this code outside XCode and launch app throught Terminal.app for see logs, logs:
2016-12-21 00:08:05.564 AppMake[9410:252746] Paths in recentDocumentURLs
2016-12-21 00:08:05.566 AppMake[9410:252746] Path: file:///Users/Manuel/Documents/Modelos%203D/X_single_Ring_round_40.stl
2016-12-21 00:08:05.566 AppMake[9410:252746] Path: file:///Users/Manuel/Documents/Modelos%203D/pirinola.stl
2016-12-21 00:08:05.566 AppMake[9410:252746] Path: file:///Users/Manuel/Documents/Modelos%203D/cubo%203.stl
2016-12-21 00:08:05.566 AppMake[9410:252746] Path filename: /Users/Manuel/Documents/Modelos 3D/cubo 3.stl
2016-12-21 00:08:05.566 AppMake[9410:252746] Path temp: /Users/Manuel/Documents/Modelos%203D/cubo%203.stl
2016-12-21 00:08:05.566 AppMake[9410:252746] Path self.archivoURL: (null)
Any Idea??
Thanks Manuel