模拟启动选项

发布于 2024-12-25 04:55:33 字数 1719 浏览 0 评论 0原文

在我的 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;
}

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待"谢繁草 2025-01-01 04:55:33

(猜测您使用的是 Xcode 4.x)

Product ->编辑方案...,在Run.app下,第一个选项卡(Info)中有Launch选项。选择等待启动`。现在,当您执行构建时,运行(或只是运行),调试器将等待您手动启动应用程序。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文