My delicious.com bookmarks for March 4th through March 7th

If you're new here, you may want to subscribe to my RSS feed or you can register for email updates. Thanks for visiting!

  • On Apple suing HTC – Like many people, I just don't see Apple's actions here being very constructive. Seems like a waste of money and good will.
  • Curiosity – "Curiosity is one of the most underrated phenomena in the world. It's ironic that people aren't more curious about curiosity. It's a powerful thing."

My delicious.com bookmarks for February 15th through February 26th

  • Tits and Apps – About most of the 'sexy' iPhone apps being pulled last weekend: "What developers see is that the App Store is a shaky foundation upon which to build a business. One day you’re prospering, the next day your app is gone. There are awesome iPhone OS apps that aren’t being built because developers don’t trust Apple not to yank the carpet out from underneath them."
  • Infer.NET – Seen at the BCS/IET Turing Lecture by Chris Bishop. Looks interesting.
  • Sources offer peek at Adobe Creative Suite 5 for Mac – PhotoShop CS5: what do you do to the app that has everything? Not a lot, visually at least…

iPhone Dev: Saving State

I see every now and again that Apple needs to make it easier to allow developers to save the state of their application so that they open up exactly as they were when they were shut down.

Obviously I’m all for Apple making my life easy, but that’s not going to happen for a while yet so I thought I’d share how I implemented it in Yummy.

The key is this simple protocol:


@protocol SaveState

- (NSData*) saveState;
- (id) initWithSaveState:(NSData*)data;

@end

This is what I have in my applicationWillTerminate: method:


NSMutableArray* vcList = [NSMutableArray arrayWithCapacity:3];
for (UIViewController* vc in self.navigationController.viewControllers) {
    // Classes that don't implement the SaveState protocol will be ignored
    if ([vc conformsToProtocol:@protocol(SaveState)]) {
        NSArray* state = [NSArray arrayWithObjects:NSStringFromClass([vc class]),
                                                                     [(UIViewController*)vc saveState],
                                                                     nil];
        [vcList addObject:state];
    }
}

This is in the applicationDidFinishLaunching::


for (NSArray* screen in screenList) {
    UIViewController* next =
                [[NSClassFromString([screen objectAtIndex:0]) alloc]
                                   initWithSaveState:([screen count] == 2) ?
                                   [screen objectAtIndex:1] : nil];
    if (next != nil) {
        [[self navigationController] pushViewController:next animated:NO];
        [next release];
    }
}

So a simple example, for a view controller that needed to be remembered but didn’t need to store any extra state, would be:


- (NSData*) saveState {
    return nil;
}

- (id) initWithSaveState:(NSData*)data {
    return [self init];
}

But you can initialise each view controller with anything that can be converted into an NSData. (I picked NSData rather than, say, id because an NSData can always be serialised. Made sense to make that assumption.)

One weakness is that it doesn’t cope with the situation where a modal view is on top but that should be pretty easy to implement if it’s important (it generally isn’t in Yummy).

My delicious.com bookmarks for February 2nd through February 7th

My delicious.com bookmarks for January 27th through January 31st

  • Who Can Do Something About Those Blue Boxes? – "Used to be you could argue that Flash, whatever its merits, delivered content to the entire audience you cared about. That’s no longer true, and Adobe’s Flash penetration is shrinking with each iPhone OS device Apple sells."
  • Penguins, Peaks and Penny-Farthings: Nat Geo Covers 1959-2000 – "The National Geographic Society celebrates its 122nd anniversary on Jan. 27 … Though the early issues had rather drab academic looking covers, by 1959 they were consistently adorned with eye-cathing art and photos."
  • Verified by Visa bitchslapped by Cambridge researchers – "Secondary credit card security systems for online transactions such as Verified by Visa are all about shifting blame rather then curtailing fraud, Cambridge University security researchers argue." Or put another way: those annoying screens you get when you buy something online are not for your benefit.

My delicious.com bookmarks for January 16th through January 22nd