Search
Powered by Squarespace
Stalk Richard

 
Article Topics
Main | Lack of Control in OS X development »
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];
}

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>