I'd like to know how to serialize an NSAttributedString to consecutively being able to store it in a core data managedObjectContext. However, I found this answer but there is no further explanation in the thread. Can somebody explain (in a nutshell) how to manually encode the attributed string? It would be highly appreciated!
Many thanks!
EDIT:
This is what I do:
NSMutableData *renderCacheData = [[NSMutableData alloc] init];
NSKeyedArchiver *renderCacheArchiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:renderCacheData];
[renderCacheArchiver encodeObject:bSelf.attString forKey:@"aS"];
At the last line it fails, the output is as following:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType encodeWithCoder:]: unrecognized selector sent to instance 0x1c538a70'
Now as I understood the other Questions in here, this is due to CT* objects not being able to serialize themselves (my NSAttributedString attributes dict contains a CTFont and CTColorRef attributes. The only thing is - I've got no idea how to write a category or (unlikely?) subclass on those types, so they are able to serialize themselves.