Search
Powered by Squarespace
Stalk Richard

 
Article Topics

Entries in NSOutlineView (1)

Sunday
Jan042009

NSConcreteAttributedString Ugliness

Ok I was struggling with updating a homegrown datasource for an NSOutlineView. What I ran into was that the method outlineView:setObjectValue:forTableColumn:byItem which you need to implement to capture the edits of an item gets passed in an (id)object in my case that is coming across as an NSConcreteAttributedString which is an internal class of NSAttributedString. Converting it and getting it back into my data source node was a little bit of bear. Here is what I came up with that works, though I haven't tested for memory leaks and such, and note I am using GC for this project.

- (void)outlineView:(NSOutlineView *)outlineView
setObjectValue:(id)object
forTableColumn:(NSTableColumn *)tableColumn
byItem:(id)item {
NSAttributedString *newattname =
[[NSAttributedString alloc] initWithString:[(NSAttributedString *)object string]];
[item setAliasName:newattname];
}