In a document based application I am able to save/read from a file, but the problem comes when I have to read from a pure plain text file.
I have only a string to read/write, so that's the code:
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
code=[codeView string];
return [NSKeyedArchiver archivedDataWithRootObject: code];
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
{
code=[NSKeyedUnarchiver unarchiveObjectWithData: data];
return YES;
}
The problem is that saving a NSData may produce a file like this one:
bplist00‘X$versionX$objectsY$archiverT$top�܆£
U$null“
V$classYNS.stringÄP“Z$classnameX$classes_NSMutableString£XNSStringXNSObject_NSKeyedArchiver—TrootÄ#-27;AFMWYZ_jsÖâíõ≠∞µ����������������������������∑
Unreadable for humans, and unreadable for other applications like text edit.I need to be able to read and save plain text files, in my plist file I already tried to achieve this by changing the document type name to public.text.
How do I save/read a pure string, encoded in UTF-8?