【问题标题】:How to create a new instance of an NSDocument with NSDocumentController?如何使用 NSDocumentController 创建 NSDocument 的新实例?
【发布时间】:2013-10-07 12:22:19
【问题描述】:

我试过了

[[NSDocumentController sharedDocumentController] duplicateDocumentWithContentsOfURL:nil
                                                                            copying:NO
                                                                        displayName:nil
                                                                              error:NULL] ;

但它不起作用。我有错误

typeForContentsOfURL:error: must be overridden for your application to support non-'file:' URLs.

【问题讨论】:

    标签: macos cocoa nsdocument nsdocumentcontroller


    【解决方案1】:

    您是否尝试过如下方式:-

       [[NSDocumentController sharedDocumentController]newDocument:self];
    

    【讨论】:

    • 谢谢!!我正在寻找错误的关键字:create 而不是 new !!
    【解决方案2】:

    我不太了解NSDocument+NSDocumentController 机器,但这是我的猜测。由于我正在回答我自己的问题,请不要犹豫发表评论或做出反应。

        [[NSDocumentController sharedDocumentController] addDocument:[[Document alloc] initWithType:nil
                                                                                          error:NULL]] ;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多