Twitter It!

Starting to write Cocoa for Mac OS X oder iOS? Have a look at these sites:

Twitter It!

I really wonder, why Apple dropped support for NSMailDelivery since Mac OS 10.5.  In fact, all methods of NSMailDelivery are declared as:

AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5

Too bad. Even worse, Apple didn’t provide an alternative – except calling ScriptingBridge as seen in the SBSendEmail sample.

Today, the best option available is CSMail from Corriolis systems. CSMail sends Emails through Apple.Mail (or some other mail clients).

For historical reasons, I mention the no longer maintained Pantomime (LGPL license), MailCore (New BSD license) and EdMessage (BSD syle license).

Twitter It!

This snippet converts a NSAttributedString to HTML markup returned as NSString:

+ (NSString*) htmlForAttributedString:(NSAttributedString*) attrString {
  NSArray * exclude = [NSArray arrayWithObjects:@"doctype",
     @"html",
     @"head",
     @"body",
     @"xml",
     nil
     ];
  NSDictionary * htmlAtt = [NSDictionary
     dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,
     NSDocumentTypeDocumentAttribute,
     exclude,
     NSExcludedElementsDocumentAttribute,
     nil
   ];
  NSError * error;
  NSData * htmlData = [attrString dataFromRange:NSMakeRange(0, [attrString length])
        documentAttributes:htmlAtt error:&error
  ];
  //NSAttributedString * htmlString = [[NSAttributedString alloc]
     initWithHTML:htmlData
     documentAttributes:&htmlAtt
     ];
  NSString * htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
  return htmlString;
} // htmlForAttributedString