模拟启动选项

Fas*_*ser 4 debugging xcode launching-application ipad ios

在我的appDelegate,我有一些规格当应用程序启动与来自ie邮件应用程序的文件.

当我启动我的应用程序时,一切正常.当我通过Mail中的文件启动应用程序时,应用程序崩溃了.不幸的是,我无法调试它,因为我无法模拟launchingOptions.此刻,我建立并运行,然后断开iPad,关闭我的应用程序,然后去邮件等...有没有办法调试?

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;
}
Run Code Online (Sandbox Code Playgroud)

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);
}
Run Code Online (Sandbox Code Playgroud)

Fil*_*lic 14

(猜猜你使用的是Xcode 4.x)

Product -> Edit Scheme...并在第一个标签()中Run <appname>.appLaunch选项Info.选择Wait for <appname.app>启动`.现在,当您执行构建和运行(或只是运行)时,调试器将等待您手动启动应用程序.