EXAMPLE - normal
- (NSData*)dataRepresentationOfType:(NSString*)type
{
NSData* mySavingData;
NSRange mySavingRange;
mySavingRange.location = 0;
mySavingRange.length = [[htmlSource textStorage] length];
mySavingData = [htmlSource RTFFromRange:mySavingRange];
// Create data from stirng with encoding
return mySavingData;
}
この関数は保存の際に勝手に呼び出される。
NSTextView ---> NSStorage に変換し、NSStorageのlengthメソッドでlengthを取り出している。
EXAMPLE - using file wrapper
ファイルラッパを使った保存
- (NSFileWrapper *)fileWrapperRepresentationOfType:(NSString*)type
{
NSData* mySavingData;
NSRange mySavingRange;
mySavingRange.location = 0;
mySavingRange.length = [[htmlSource textStorage] length];
mySavingData = [htmlSource RTFDFromRange:mySavingRange];
NSFileWrapper *wrapper = [[htmlSource textStorage] RTFDFileWrapperFromRange:mySavingRange documentAttributes:(NSDictionary *)NULL];
// Create data from stirng with encoding
return wrapper;
}


