gpt4 book ai didi

cocoa - "Building a Text Editor in 15 Minutes"引用示例不起作用

转载 作者:行者123 更新时间:2023-12-03 18:06:05 25 4
gpt4 key购买 nike

我正在尝试使用 NSDocument,所以我尝试了 Building a Text Editor in 15 Minutes文本系统概述引用中的示例。

我对建议的代码进行了一些更改,例如使用属性和合成来代替声明和定义访问器方法。

我按照引用文献中编写的每个步骤进行操作,但无法实现第 5 步:

If it is not already open, double-click MyDocument.xib to open the document window in Interface Builder. From Xcode, drag the MyDocument.h file icon onto the document window of MyDocument.xib. This step informs the MyDocument.xib file that the MyDocument object interface now has an outlet variable named textView.

当我编译时,它在 NSDocument 的子类中给出了以下警告:

myDocument may not respond to setString

MyDocument 窗口没有出现,并且每次我尝试执行它时控制台中都会出现此消息:

-[MyDocument string]: unrecognized selector sent to instance 0x215970

谁能告诉我哪里可能错了?我正在尝试在 Snow Leopard 上运行它...要检查代码,您也可以从 here 下载它.

最佳答案

I am trying to work on NSDocument, so I tried the Building a Text Editor in 15 Minutes example in the Text System Overview reference.

I did some changes to code which was suggested, such as used property and synthesize in place of declaring and defining accessor methods.

我知道这已经很老了,但是该示例使用了 ivar NSAttributedString *mString; 因此您需要更改名称或使用类似以下内容:-

@property(copy, getter=string, setter=setString:) NSAttributedString *mString;

关于cocoa - "Building a Text Editor in 15 Minutes"引用示例不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2238641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com