xcode 如何制作一个简单的 Cocoa/Objective-C 文本编辑器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16378568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:19:59  来源:igfitidea点击:

How do you make a simple Cocoa/Objective-C text editor

objective-cxcodecocoatext-editor

提问by Ben Dowling

I want to know how to make a very, very simple text editor with Xcode. I only want it to be able to save, load, and write text files. I am just doing it out of curiosity.

我想知道如何使用 Xcode 制作一个非常非常简单的文本编辑器。我只希望它能够保存、加载和写入文本文件。我只是出于好奇而这样做。

回答by Rod Schmidt

Here's a complete project for TextEdit the text editor that comes with OS X: https://developer.apple.com/library/mac/samplecode/TextEdit/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011741

这是 OS X 附带的文本编辑器 TextEdit 的完整项目:https: //developer.apple.com/library/mac/samplecode/TextEdit/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011741

If you want to start from scratch and do it yourself, take a look at the NSTextField class, or for saving, take a look at NSArchiver. All your pretty much have to do is create a new project, add an NSTextField to your window, and write the code to load and save the file.

如果你想从头开始自己做,看看 NSTextField 类,或者为了保存,看看 NSArchiver。您几乎要做的就是创建一个新项目,将 NSTextField 添加到您的窗口,然后编写代码来加载和保存文件。

Get the book Cocoa Programming for Mac OS X by Aaron Hillegass. It will show you how to get started, or just check out developer.apple.com. Lots of documentation there.

获取 Aaron Hillegass 所著的 Cocoa Programming for Mac OS X 一书。它将向您展示如何开始,或者直接查看 developer.apple.com。那里有很多文档。