Monthly Archives: December 2011

Microblogging is Weblogging

Reuters [Anthony De Rosa]: “The difference between the two is that microblogs tend to rely heavily on short bursts of information: links, photos, videos and brief messages. Blogger fatigue gave way to sharing smaller, less labor intensive bits of content.”

In the wayback, before the time of Twitter, Tumblr, and Posterous, we had what were referred to as weblogs, or blogs for short (a word I absolutely hate.)

When I started my weblog in 2001 I’d post small, less labor intensive bits of content, like pictures, links, and brief messages. My weblog looked more like my Twitter stream looks today. Go look at the archives, you’ll find many examples.

Anywho, I find all the talk about weblogging being dead, tiring. It’s alive and well in late 2011, and I’m sure it’ll continue to thrive in 2012. It’s just doing what everything else does, it’s evolved.

Objective-C Objects from JSON

I was asked recently how to create an Objective-C Object from a JSON result returned by a RESTful service. Man, that’s a mouthful.

It’s actually fairly easy, especially if you make use of the excellent JSONKit by John Engelhart. The example below does just that.

For starters I created a simple Cocoa Application and changed main() so it returns 0, because we don’t need to show a window and have an event loop. Here’s a link to the complete main.m.

Next add JSONKit.m and JSONKit.h to your project, and build. That’s it. It should just work.

Here’s what the code does.

For starters we define some sample JSON. This is very rudimentary. The object contains a firstName and lastName field. This is meant to represent the data returned by our pretend REST service.

static NSString* const kSampleJSON = @"{\"firstName\": \"Rob\", \"lastName\": \"Fahrni\"}";

Next up we define a Person interface.

@interface Person : 
    NSObject
{
@private
    NSString* _firstName;
    NSString* _lastName;
}

@property (copy) NSString* firstName;
@property (copy) NSString* lastName;

- (id)initWithDictionary:(NSDictionary*)dict;
- (void)dealloc;

@end

Again, very simple. This Person interface has first name(_firstName) and last name(_lastName) members and is initialized by passing it an NSDictionary*. So far, it looks pretty easy, right? Right!

The next thing we need to do is implement Person. Once again, no rocket science here. It’s straight Objective-C.

@implementation Person

@synthesize firstName = _firstName;
@synthesize lastName = _lastName;

- (id)initWithDictionary:(NSDictionary *)dict;
{
    if ((self = [super init]))
    {
        _firstName  = [dict valueForKey:@"firstName"];
        _lastName   = [dict valueForKey:@"lastName"];
    }
    
    return self;
}

- (void)dealloc;
{
    [_lastName release];
    [_firstName release];
    
    [super dealloc];
}

- (NSString*)description
{
    // Overriding description allows you to print something meaningful
    // to the debug output window. In this case we'll print 
    // Rob Fahrni.
    return [NSString stringWithFormat:@"%@ %@\n", _firstName, _lastName];
}

@end

Ah! Now we’re getting somewhere. Notice the Person is constructed with an NSDictionary* that should contain at least two entries; firstName and lastName. Note “firstName” and “lastName” just so happen to match our simple JSON constant, defined as kSampleJSON. That’s because it’s the source of our data.

Something else of note is the method description. By overriding NSObject description we allow NSLog to dump something meaningful when we give an instance of Person as an argument. You’ll see that used below. It’s darned handy when you’re debugging.

UPDATE 12/31/2011: I noticed I’d used objectForKey instead of valueForKey when assigning to _firstName and _lastName.

Finally we can test our code to see what it does.

int main(int argc, char *argv[])
{
    // Pretend like you've called a REST service here and it returns a string.
    // We'll just create a string from the sample json constant at the top
    // of this file.
    NSString* responseJSON = [NSString stringWithFormat:@"%@", kSampleJSON];
    
    // 1) Create a dictionary, from the result string,
    // using JSONKit's NSString category; objectFromJSONString.
    NSDictionary* dict = [responseJSON objectFromJSONString];
    
    // 2) Dump the dictionary to the debug console.
    NSLog(@"Dictionary => %@\n", dict); 
    
    // 3) Now, let's create a Person object from the dictionary.
    Person* person = [[[Person alloc] initWithDictionary:dict] autorelease];
   
    // 4) Dump the contents of the person object
    // to the debug console.
    NSLog(@"Person => %@\n", person);

    return 0;
}

That’s all there is to it? Yep, that’s it! Pretty simple, right?

Backing up Twitter

I’ve wanted a way to get my entire stream of updates out of Twitter for a very long time. I’ve been using Backupify, which is ok. A friend just pointed me to The Exporter, which will email you an XML backup of your stream. It’s really nice, but not quite what I’m after.

Dave Winer has been working on his Scripting 2 system, which I think may have this capability, but I’m not sure.

I’m of two minds on the subject.

The Easy Version

I’d love to find a service that would allow me to specify an FTP, a backup strategy, an archive layout, and have it push HTML or XML to the my site. This way I could have something like fahrni.ws/twitter/archive/YYYY/MM/DD as the home of my Twitter stream. I’d have an index at the root of fahrni.ws/twitter that would have a week, or two, of tweets and a link at the bottom of the page that would allow me to navigate backward and forward through a week at a time. Sounds simple, but I’m sure it would take a bit of time to create it.

The Difficult Version

I say difficult because I think it would be awesome to define an open REST interface that could be used as a backup mechanism for anything. Once the interface is defined the tough work would begin. It would need to have implementations that are then hooked up to services that can communicate with them.

For instance, let’s say you implement this new REST interface on your server, who in the world is going to make calls to it? Someone else? Maybe. It could be you implement both sides of the equation.

Come to think of it this could be implemented using an RSS feed out of Twitter and some code on a server somewhere that knows how to pull the RSS from the server. That would be pretty slick.

It needs to be simple

In the end I want something so simple I can set it and let it go. I also REALLY want to capture every tweet I’ve ever posted. That, is the biggest deal to me. I want the entire stream.

The conversation that sparked this post

This post came out of a conversation started where? On Twitter, of course.

Twitter Backup Conversation.

You said what?

The Telegraph: “But someone had entered the obscene seven-word phrase as the user’s name, so the phone blurted it out when it answered a question.”

The headline for the article is sensational, “iPhone Siri software tells boy, 12, to ‘shut up’ in Tesco”, but it does its job. I had to go see why Siri would say the eff word to a kid. Turns out someone typed the phrase as the users name. Siri was addressing the user.

Not as clever as I had expected. I thought it was going to be a genuine hack, not a prank a 10 year old could play.

Social Overload

AHHHHHH!Like a lot of folks I’ve been suffering from Social Overload, or SO for short. With the introduction of Stamped, Arrived, and Path it got even crazier for about a week. After using, or considering some of these newcomers I made some decisions.

My Favorite

Path, without a doubt is my new favorite Social Network. It’s what Facebook could have been if it had been carefully designed, as Path was. If I were a mobile developer at Facebook I’d be jealous of the job the fine folks at Path have done. It’s beautifully designed, contrary to what some designers think. The timeline was beautifully executed and I love the little touches like Covers, which amount to nothing more than a wallpaper for your path. It’s a tiny thing but it really makes the app feel like it’s yours. After spending a few days with Path I started thinking to myself “Where does this leave Gowalla in my mix of apps?”, but we’ll get to that later.

Path is a really nice mix of check-in based apps, like Gowalla and Foursquare, and social network sites like Twitter and Facebook. It fits right in that sweet spot for me. Twitter is minimal, which I love, and Facebook is overbearing and ugly.

Bottom line, I love Path.

The Non Starter

I jumped on Arrived when I heard about it, but I never really got into it. I think it required my phone number to sign up, which I didn’t want to give out. It also has links to Facebook, which is a turnoff. I don’t remember if it requires the use of a Facebook account? Maybe someone can clarify that for me?

I like the look of the UI. It looks leathery, with stitches. I’m sure some designers will love it, others will hate it.

Stamped

I love the look of this application and it’s super simple. With Stamped you stamp things you like. What could be easier? I think I’ll keep this one around for a while and give it a fair chance. It came out just before Path 2.0, which is unfortunate. Path just stole my attention.

Goodbye, Facebook

I’ve been struggling with the idea of closing down my Facebook account for a while now and with the introduction of Path I just don’t need it anymore. If family and friends need to get in touch with me there’s always the phone, my web home, email, Twitter, and Path. Many, many, ways to get in touch.

A few nights ago I deleted my Facebook account and I haven’t missed it.

Gowalla, Bummer

I say bummer because I actually liked Gowalla, and used it more than Foursquare. I was pulling for the little guy and I liked the company.

Gowalla is no more. It’s now a Facebook property and I have no idea what that means for the service. I suppose it will be lost somewhere in the bowels of Facebook, just more plumbing. I’d love to see how that integration works. How will the folks from Austin, Texas, gel with folks in California? I suppose we’ll see. I hope it works well for them.

Another question, how long with that Tumblr based Gowalla weblog exist? The links above may suffer from link rot in a few years, who knows?

Gowalla had some fine folks working on it and they’re fleeing like rats from a sinking ship, not that I blame them. I’m not sure I’d like to work for Facebook myself.

Tim Van Damme is moving on to Instagram, which is kind of weird given this post, and quote.

In 10 years we’ll look back at apps like Instagram and Hipstamatic and chuckle. “What were we thinking?”

Then again, maybe that’s why Instagram hired him. Maybe he has a way to fix the problems he sees with the service?

Another Gowalla’ite, Phillip McAllister is also joining Instagram.

But, I digress. It definitely made me feel even better about using Path. The Gowalla team is no more, Gowalla the app, and service, are no more. Makes deleting the application from my phone a no brainer.

In and Out

In – Path and Stamped.
Out – Facebook and Gowalla.

Mike Ash on Objective-C Blocks

Duct Tape, fixer of all things!Mike Ash: “Both Objective-C blocks and C++0x lambdas have the same basic goal: to allow writing anonymous inline functions. Called closures, blocks, lambdas, or just anonymous functions, these are a common feature in higher level languages. They are extremely useful for building convenient, succinct libraries for things like array iteration, multithreading, delayed computation, and many others.”

Mike explores Objective-C Blocks and C++ Lambdas. This article is six months old, but it’s still very relevant and great as always. If you’re a Cocoa Head you should definitely add Mike’s RSS feed to your preferred news reader.

2011 Box Office Down

New York Times: “LOS ANGELES — With five days left in 2011, ticket sales in North America are running about $500 million behind last year — despite higher prices — prompting a round of soul searching by studios trying to determine what went wrong and how best to proceed.”

The article goes on to say higher 3D ticket sales propped up the box office, but I definitely don’t agree. I prefer 2D to 3D any day of the week. 3D is a gimmick, nothing more. It doesn’t do anything to enhance the experience unless you’re interested in seeing something hurled at you. It doesn’t make the story better and the film is darker. Who wants to see a film with poor lighting? I certainly don’t.

I hope movie studios focus their effort on better stories in 2012. I don’t need “Sharks 3D.” I’m looking forward to The Hobbit, Batman, and Prometheus. I really hope all of them give us a 2D option. Heck, I’m more interested in seeing a film shot at 48fps than ever seeing another 3D movie.

Merry Christmas!

Merry Christmas!

An angel of the Lord appeared to them, and the glory of the Lord shone around them, and they were terrified. But the angel said to them, “Do not be afraid. I bring you good news of great joy that will be for all the people. Today in the town of David a Savior has been born to you; he is Christ the Lord. This will be a sign to you: You will find a baby wrapped in cloths and lying in a manger.”Luke 2:9-12

Fulton Mall Fiasco

Huffington Post: “The site is being re-examined and this past October three options for remaking the mall (narrowed down from 10) were unveiled — two could significantly destroy the character of the mall by opening it up to cars with a traditional street or inserting two lanes of road and curbs weaving them through some of the outdoor “vignettes” while demolishing others. The third, complete restoration, is most likely not economically viable. The one really sensible solution — keeping four of the six streets closed to cars while opening many of the cross streets, a realistic compromise balancing design, historic preservation and economics — inexplicably seems to have been abandoned.”

I wonder if someone believes that tearing Fulton Mall apart will actually help downtown?

The city needs to work a whole lot harder to attract a large employer downtown. A modern, younger, company that will encourage other companies to relocate. Naive? Yep.