7

in my appDelegate, I have some specifications when the App is launch with a File from i.e. Mail app.

When I launch my App, everything works normal. When I launch the App via File from Mail, the App crashes. Unfortunately, I am not able to debug it as I can't simulate launchingOptions. at the moment, I build and run, then disconnect the iPad, close my App and then go to mail etc … Is there a way to debug?

Appdelegate.m

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

NSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];

IntroViewController *introViewController = (IntroViewController *)self.window.rootViewController;

if (url !=nil) {
    if ([url isFileURL]) {
        introViewController.fileUrl = url;
    }


}

NSLog(@"%@",[url path]);

return YES;
}

IntroViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSLog(@"Hello");
    if (fileUrl != nil) {
        IntroTableViewController* introTable = (IntroTableViewController *)segue.destinationViewController;            
        introTable.openedByURL = [fileUrl path];

        TabBarController* tabBarController = (TabBarController *)segue.destinationViewController;
        UINavigationController* navigationController = (UINavigationController *)[[tabBarController viewControllers] objectAtIndex:0];
        TargetLSController* targetViewController = (TargetLSController *)[[navigationController viewControllers] objectAtIndex:0];
        NSString *urlPath = [fileUrl path];
        targetViewController.currentFilePath = urlPath;
        NSLog(@"%@",urlPath);
    }
}

- (void)viewDidAppear:(BOOL)animated
{
    [self performSegueWithIdentifier:@"Launch" sender:self]; 
    NSLog(@"%@",fileUrl);
}
beryllium
  • 29,669
  • 15
  • 106
  • 125
Faser
  • 1,256
  • 1
  • 18
  • 36

1 Answers1

19

(Guessing you use Xcode 4.x)

Product -> Edit Scheme... and under Run <appname>.app there is Launch option in first tab (Info). Select Wait for <appname.app> to launch`. Now when you perform build & run (or just run), debugger will wait for you to launch the app manually.

Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
  • Great, thank you very much! Unfortunately, no NSLog is fired anymore? – Faser Jan 04 '12 at 13:31
  • 1
    You might still be able to see the output from NSLog in the Mac OS X Console.app. Alternatively, if you are running on a device, you might be able to see it in Organizer >> Devices, plug in a device, then select it's Console. – Andrew Ebling Sep 21 '12 at 14:37