mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-28 22:47:04 +00:00
NEW: CPCoding for CPAttributedString
This commit is contained in:
@@ -816,6 +816,42 @@
|
||||
//do nothing (says cocotron and gnustep)
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(id)aCoder
|
||||
{
|
||||
self = [self init];
|
||||
if (self != nil)
|
||||
{
|
||||
_string=[aCoder decodeObjectForKey:"_string"];
|
||||
var decoded_ranges = [aCoder decodeObjectForKey:"ranges"],
|
||||
decoded_attribs = [aCoder decodeObjectForKey:"attributes"];
|
||||
_rangeEntries=[];
|
||||
|
||||
var i, l= decoded_ranges.length;
|
||||
for(i = 0; i < l; i++)
|
||||
{
|
||||
_rangeEntries.push(makeRangeEntry(decoded_ranges[i], decoded_attribs[i]));
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(id)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_string forKey:"_string"];
|
||||
|
||||
var ranges_for_encoding = [],
|
||||
dicts_for_encoding = [];
|
||||
|
||||
var i, l = _rangeEntries.length;
|
||||
for(i = 0; i < l; i++)
|
||||
{
|
||||
ranges_for_encoding.push(_rangeEntries[i].range);
|
||||
dicts_for_encoding.push(_rangeEntries[i].attributes);
|
||||
}
|
||||
[aCoder encodeObject:ranges_for_encoding forKey:"ranges"];
|
||||
[aCoder encodeObject:dicts_for_encoding forKey:"attributes"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user