Sunday
Jan042009
NSConcreteAttributedString Ugliness
Sunday, January 4, 2009 at 04:33AM 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];
}
tagged
NSOutlineView,
Objective-C in
Mac Development,
Programming
NSOutlineView,
Objective-C in
Mac Development,
Programming 

Reader Comments