Wednesday, October 5, 2011

Why all the disappointment?

I keep seeing all these blogs/threads about how Apple blew it by not putting out a iPhone 5. But honestly, what would the iPhone 5 consist of that the 4S does not already cover? I can think of one thing: some new spiffy form factor with a slightly bigger screen.

As for form factor, the iPhone4 is already quite good. Is it just because we want something different, and not necessarily better? I don't think they could make things thinner with all the new guts they stuffed into the same case. A bigger screen, but same resolution... I'm not convinced that this would be all that much of an improvement. I certainly don't want a bigger phone, the iPhone 4 fits perfectly in the hand.

We know LTE would not be in the cards. It just isn't ready yet, and Apple isn't big on adopting technologies preemptively (unless they are innovating it themselves.)

So as for the 4S, let's list the highlights:

* A5 chip, x7 graphics
* longer battery life
* new antenna design
* 2x data speed over 3G
* enhanced camera
* CDMA/GSM in same phone
* iOS5/iCloud
* Find my Friends / Cards
* iTunes Match
* Siri

Ok, that is a pretty solid list of improvements. This really is a new phone, but just in the same form factor. Had we wrapped all this up in a new form factor and called it iPhone 5, would it suddenly get the praise and glory?

I think it's mostly perception. As a matter of fact, if Steve Jobs would have been the one on stage, I think things would have been perceived differently. He has a way of wowing the audience. "We started from scratch. We took the already beautiful iPhone 4 form factor, gutted it, and replaced every single component with something better."

[note] this is a copy of my post here.

Friday, February 4, 2011

Objective-C Semi-Singleton Class

Sometimes when building an iOS application, you will have a class you will want to access from anywhere. Such as, a controller with any number of child controllers (navigation, tab, etc.) and some of them need simple access back to the root controller.

Apple provides their own solution to creating a full-blown singleton class, but this can be a daunting task for a simple need. A semi-singleton is much easier to create but has two caveats:

1) semi-singletons only work if there is ever only one instance of the class
2) the singleton cannot be used to initialize itself

So, here is how to make a simple "HelloWorld" class into a semi-singleton.

In the HelloWorld.m file, create a static property to hold the singleton instance:


// put just after @implementation line
static HelloWorld* helloWorldInstance;


in the init method, assign the instance (self) to the static property:


-(id) init
{
if ((self = [super init]))
{
// assign the semi-singleton
helloWorldInstance = self;
// do other init stuff here ...
}
return self;
}


create the shared static method for accessing the semi-singleton:


+(HelloWorld*) sharedInstance {
return helloWorldInstance;
}


Lastly, be sure to dealloc the property to avoid crashes:


-(void) dealloc
{
helloWorldInstance = nil;
[super dealloc];
}


And now from any class, we can access a pointer to the instance:


#import HelloWorld.h

HelloWorld *helloWorld = [HelloWorld sharedInstance];


And there you have it. Thanks to Steffen Itterheim and his book about cocos2d programming for the original tip!