如何在objective-c中的iTXt png块中保存文本?
我找到a description of the PNG format,示例in Java和in PHP,但无法弄清楚如何在objective-c上执行此操作。
如何阅读保存的信息?
答案 0 :(得分:-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/
答案 1 :(得分:-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