My application can read .txt files opened using the "open with ..." dialog. I implemented my reading functions as in
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
and
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
methods.
Interestingly, it only works if the application has been opened. If I open the .txt file in ie Mail and select "open with", then my application. I see in the console that
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
called out. I can also see the URL of the correct file, which is supposedly located in
File: //localhost/private/var/mobile/Applications/F15C57D0-4F62-4979-943A-2D387488D59C/Documents/Inbox/myFile.txt
But when I try to open the file, I get a Cocoa error that the files do not exist.
If I repeat the steps (when opening the application in the background) than the file is found, and it works immediately. Why is this?
source share