Simulate Launch Options

笑着哭i 提交于 2019-12-19 03:37:00

问题


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);
}

回答1:


(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.



来源:https://stackoverflow.com/questions/8725625/simulate-launch-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!