One Quickie

Putting an image into an attributed string (NSString->General)
You'll need to use a text attachment.
- (NSAttributedString *) prettyName
    NSTextAttachment *attachment;
    attachment = [[[NSTextAttachment alloc] init] autorelease];
    NSCell *cell = [attachment attachmentCell];

    NSImage *icon = [self icon]; // or wherever you are getting your image
    [cell setImage: icon];

    NSString *name = [self name];
    NSAttributedString *attrname;
    attrname = [[NSAttributedString alloc] initWithString: name];

    NSMutableAttributedString *prettyName;
    prettyName = (id)[NSMutableAttributedString attributedStringWithAttachment:
                                                attachment]; // cast to quiet compiler warning
    [prettyName appendAttributedString: attrname];

    return (prettyName);

} // prettyName
This puts the image at the front of the string. To put the image in the middle of the string, you'll need to create an attributedstring with attachment, and then append that to your final attributed string.

borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book