如何创建包含文本和图像的自定义文件类型?
我知道这有点难以回答,但我需要将文本和图像保存到一个文件中(就像 Photoshop 所做的那样)。我应该创建自定义文件类型,还是有其他方法可以做到这一点?
如果我需要自定义文件类型,有人可以给我一些可以帮助我使文件类型正确存储数据的链接吗?如果有其他方法,我该怎么做?
注意:我在导入三个图像的应用程序中使用它,并允许用户在它们上面放置文本,因此我可能无法获取以任何方式将图像存储为文本所需的信息。如果这是我必须做的,我将需要一些有用信息的链接。
I know this is going to be somewhat hard to answer, but I need to save text and images into a single file (like photoshop does). Should I make a custom file type, or is there another way to do this?
If I need a custom file type, would somebody please give me link to something that may help me make the file type store the data properly? If there is another way, how can I do this?
NOTE: I am using this in a application that imports three images, and lets users put text over them, so I may not be able to get the information needed to store the images as text in any way. If it is what I have to do, I will need a link to some helpful information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将对象保存到文件的一种简单方法是将它们添加到 NSDictionary 中,然后使用 NSArchiver 将字典存档到数据中。
例如,在基于文档的应用程序中:
要读取此数据,只需取消存档字典并设置对象:
您还需要在应用程序的 plist 文件中定义自定义文件类型。
An easy way to save objects to a file is to add them to an
NSDictionary
and then useNSArchiver
to archive the dictionary into data.For example in a document based app:
To read this data, just unarchive the dictionary and set the objects:
You will also need to define your custom file type in your app's plist file.