1

如何在objective-c的iTXt png块中保存文本?

我找到了 PNG 格式的描述,JavaPHP中的一个示例,但无法弄清楚如何在 Objective-c 上做到这一点。

如何读取保存的信息?

4

2 回答 2

-2

此外,为了将自定义对象保存在文件中,您的对象必须符合 NSCoding 协议。在此处查看详细信息:http: //developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html

这意味着您的对象类必须实现:

– initWithCoder: 
– encodeWithCoder:

一旦你有一个符合 NSCoding 协议的对象,你就可以使用 NSKeyedArchiver/NSKeyedUnarchiver 从文件读取和写入数据。在此处查找参考资料:

NSKeyedArchiver:http: //developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSKeyedArchiver_Class/Reference/Reference.html

NSKeyedUnarchiver:http: //developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSKeyedUnarchiver_Class/Reference/Reference.html

于 2013-02-16T21:51:37.303 回答
-2

在 Objective C 中,有几种方法可以从文件中读取数据。一般来说,大多数集合类都有类似于以下的方法:

+ arrayWithContentsOfFile:
+ arrayWithContentsOfURL:
+ dictionaryWithContentsOfFile:
+ dictionaryWithContentsOfURL:
+ stringWithContentsOfFile:encoding:error:

根据文件中存储的数据类型,您使用不同的方法。当文件中保存的数据为 PLIST 格式时,使用前 4 种方法。最后一个用于从文件中读取字符串。

注意所有这些方法都是类方法(C++中的静态类函数),还有对应的实例方法(C++中的成员函数)。

详情请参考 iOS/MAC 开发者库:http: //developer.apple.com/library/ios/navigation/ http://developer.apple.com/library/mac/navigation/

于 2013-02-16T21:46:48.007 回答