Nature

This weeks PhotoFriday, “Nature,” is a much broader theme than we’ve had in the last few weeks. So lots of choices this time — too many — and in the end I figured that showing the vastness of a natural area, barely touched by man was the way to go. This image is originally from my tribute to Ansel Adams.

Please also vote for my entry in last weeks challenge, “Lightness.” I’m entry number 220.

Share:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Facebook
  • LinkedIn
  • Slashdot
  • Diigo
  • FriendFeed
  • Identi.ca
  • Ping.fm
  • Twitter

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).

Share:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Facebook
  • LinkedIn
  • Slashdot
  • Diigo
  • FriendFeed
  • Identi.ca
  • Ping.fm
  • Twitter

Lightness

I had a really hard time finding a suitable image for this weeks PhotoFriday theme, “Lightness.” I note that a few people have submitted sunsets or sunrises. Nice, but that’s light not lightness.

I visited Iceland over Christmas and remember the constant flickering of candles and open fires and the cheer of the locals despite the long hours of darkness. This image, therefore, represents lightness both in terms of the candles and the spirit of all in the parade. (That sort of sounds cheesy when you write it down but I’m being genuine when I say it!)

Please also vote for my entry in last weeks challenge, “Surfaces.” I’m entry number 195.

Share:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Facebook
  • LinkedIn
  • Slashdot
  • Diigo
  • FriendFeed
  • Identi.ca
  • Ping.fm
  • Twitter

Corked

Don’t you just hate it when this happens? You try to push the cork-screw into the bottle and it just ends up pushing the cork right into the bottle.

Share:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Facebook
  • LinkedIn
  • Slashdot
  • Diigo
  • FriendFeed
  • Identi.ca
  • Ping.fm
  • Twitter
Share:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Facebook
  • LinkedIn
  • Slashdot
  • Diigo
  • FriendFeed
  • Identi.ca
  • Ping.fm
  • Twitter

Surfaces

Surfaces,” this weeks PhotoFriday theme, is kind of an odd subject, I mean in some sense almost everything is or has a surface. But what I liked about the Getty Museum in Los Angeles is that the whole building was strange shapes and surfaces, something that I tried to get across in this image. Which I thought made it a decent candidate for this weeks challenge.

Please also vote for my entry in last weeks challenge, “Distant.” I’m entry 189.

Share:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • Technorati
  • email
  • Facebook
  • LinkedIn
  • Slashdot
  • Diigo
  • FriendFeed
  • Identi.ca
  • Ping.fm
  • Twitter