简体   繁体   English

如何在Mac App中创建文件

[英]How to create a file in a mac app

I am new to programming mac apps in Objective-C and need help with this. 我是第一次使用Objective-C编程Mac应用程序,因此需要帮助。 When I control click and drag to first responder from a button it brings up a box from which you can select some predefined functions that run when the button is clicked. 当我控制单击并从按钮拖动到第一响应者时,它会弹出一个框,您可以从中选择一些在单击按钮时运行的预定义功能。 On of the functions says newDocument. 函数的其中一个表示newDocument。 I was wondering if this means that it creates a new document (file) and if so how to actually make it create the file. 我想知道这是否意味着它会创建一个新的文档(文件),以及是否实际如何创建它来创建文件。 I tried selecting newDocument but when I ran the app it said this: 2016-03-16 15:39:57.889 Test[26619:4382721] The (null) type doesn't map to any NSDocumentClass. 我尝试选择newDocument,但是当我运行该应用时,它说: 2016-03-16 15:39:57.889 Test[26619:4382721] The (null) type doesn't map to any NSDocumentClass. My button is simply named create file and has no code attached to it, only the predefined function. 我的按钮简称为“创建文件”,没有附加代码,只有预定义的函数。

The method you are seeing, newDocument , is part of the Document Architecture . 您所看到的方法newDocumentDocument Architecture的一部分。 If you wish to use it you need to study the documentation, the particular function newDocument creates a "document" within your app along with an associated "window" rather than a "file" per se . 如果您想使用它,则需要学习文档,特定功能newDocument会在您的应用程序内创建一个“文档”以及关联的“窗口” 本身而不是“文件”。

It sounds like you really need to read the Cocoa Event Handling Guide to learn how to handle a mouse event, and the File System Programming Guide to learn how to read & write files. 听起来您确实需要阅读《 Cocoa事件处理指南》以了解如何处理鼠标事件,以及《 文件系统编程指南》以了解如何读取和写入文件。

HTH 高温超导

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM