NSAttributedString-Encoding
NSAttributedString-Encoding copied to clipboard
CTForegroundColor serialization issue in iOS7
Hello! I serialize NSAttributedString to NSData with your library. I've got a crash with a confusing message: 'Only RGBA or White color spaces are supported in this situation.' I can reproduce the problem only in iOS7. Other iOS versions work correctly.
The "CTForegroundColor" attribute has value: "UIDeviceWhiteColorSpace 0 1" of class UICachedDeviceWhiteColor. If I remove it manually from the attributed string - then everything is OK.
On the simulator it causes EXC_BAD_ACCESS at this line:
-(NSData*) convertToData {
return [NSKeyedArchiver archivedDataWithRootObject:[self dictionaryRepresentation]];
}

On the real device it says:
Assertion failure in -[UICGColor encodeWithCoder:], /SourceCache/UIKit/UIKit-2891.1/UIColor.m:1410
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only RGBA or White color spaces are supported in this situation.'

The attributed string is the following:
lknsdvksndvklnsdklnv{
NSFont = "<UICTFont: 0x17e715a0> font-family: \"Times New Roman\"; font-weight: normal; font-style: normal; font-size: 12.00px";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 12, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}
{
CTForegroundColor = "UIDeviceWhiteColorSpace 0 1";
NSFont = "<UICTFont: 0x17e715a0> font-family: \"Times New Roman\"; font-weight: normal; font-style: normal; font-size: 12.00px";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 12, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}
I haven't run across this in iOS 7 yet. Could you show some sample code (or even better a sample project) that demonstrates this exception?
Here is a sample project: https://dl.dropboxusercontent.com/u/3792172/Samples/Book.zip
It seems that the dude has got a similar issue: http://www.cocoanetics.com/2013/09/welcome-to-ios-7-issues/