ios - 模拟启动选项

标签 ios xcode ipad debugging launching-application

在我的 appDelegate 中,当使用来自邮件应用程序的文件启动应用程序时,我有一些规范。

当我启动我的应用程序时,一切正常。当我通过邮件中的文件启动应用程序时,应用程序崩溃了。不幸的是,我无法调试它,因为我无法模拟 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);
}

最佳答案

(猜你用的是 Xcode 4.x)

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

关于ios - 模拟启动选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8725625/

相关文章:

ios - Swift - 通用应用程序中的图像失真

ios - WKWebView 与 SFSafariViewController

iphone - AVAssetWriter 多个 session 和状态属性

objective-c - 将 pdf 页面保存在多页数组中

iphone - Xcode Organizer 在哪里存储 iPhone 屏幕截图?

ios - AVAudioEngine 应用音效

ios - 如何删除 Realm 中的对象?

ios - 如何重新加载整个 UIViewController 页面

objective-c - iPad 输入密码 View

ios - 使用 CSS 模糊在 iPad 上滚动