Blog APIs

It can be quite annoying when an application claims to support an API and actually doesn’t 🙁 
I’ve been working on BlogThing off an on for about a week or so. Originally I used a bit of the metaWeblog API and a bit of the MovableType API. I’ve since standardized on metaWeblog and removed the references to MovableType. 🙂 
 
Now, I’ve successfully tested BlogThing against WordPress and Typo however, Blojsom, while it claims to support the metaWeblog API it soon becomes apparent that this is not the case 🙁

Accessing the string and attribute data in a NSTextView

NSTextView stores its data in a NSTextStorage object. NSTextStorage descends from NSMutableAttributed string, so that gives us a clue. 
The easiest thing to do is to make a category on the NSAttributedString class to do whatever it is you want containing something like the following. 
 
    NSRange range; 
    
int i; 
    
int L = [self length]; 
             
    i =
0
    
while(i<L) { 
         
// get all the attributes we are interested in 
        NSDictionary* attributes = [
self attributesAtIndex: i effectiveRange: &range]; 
        NSAttributedString* attPart = [
self attributedSubstringFromRange: range]; 
        NSString* part = [attPart string]; 
        NSFont* font = [attributes objectForKey: NSFontAttributeName]; 
        NSColor* color = [attributes objectForKey:
@”NSColor”]; 
        NSParagraphStyle* paraStyle = [attributes objectForKey: NSParagraphStyleAttributeName]; 
        NSShadow* shadow = [attributes objectForKey: NSShadowAttributeName]; 
        NSURL* link = [attributes objectForKey: NSLinkAttributeName]; 
         
        NSTextAttachment* attachment = [attributes objectForKey: NSAttachmentAttributeName]; 
         
         
// process your attributed string pieces here 
 
        i = range.location+range.length; 
    }