Friday, October 30, 2009

iPhone Friday - October 30, 2009

Hello and happy Friday.  Today's collection of iPhone and iPod touch wallpapers is the second part of a two part series entitled Bubble Series A; five pictures of bubbles taken at night.  Enjoy.










Thursday, October 29, 2009

iPhone Tech Talk World Tour 2009

We're attending Apple's iPhone Tech Talk World Tour 2009 in Santa Clara today. I went to last year's event and I highly recommend it. It's open to registered Apple iPhone developers only, but it's free and you get free breakfast and lunch and a t-shirt. And the talks are great too :-).

Tuesday, October 27, 2009

Tales of App Store Failure

Sean Maher, the creator of the iPhone zombie game Dead Panic, shares his sales figures and writes about the difficulty of building a sustainable business in Tales of App Store Failure.

Objective-C Tuesdays: the while loop

After the standard C for loop and the Objective-C 2.0 for...in loop, the while loop is the most common. Unlike the full-featured for loop and the specialized for...in loop, the while is simpler and more free-form.

The while loop starts with the keyword while followed by parentheses containing the condition. After the parentheses, a single statement or block makes up the body of the loop.
/* while loop with a single statement */
while (condition) statement;

/* while loop with a block */
while (condition)
{
  block;
}
Watch out for a hard to spot bug when the while loop is followed by an empty statement created by an extra semicolon:
while (condition); /* <-- warning! empty statement! */
{
  /* this block is not part of the loop */
  /* it's always executed exactly once  */
}
The condition in a while loop is evaluated before the body of the loop is executed, so you can create loops that execute zero or more times. If you want the body of the loop to execute one or more times, you can use a do...while loop instead.

The initialization of the loop counter or other loop variables must be done before the while loop statement; often this means declaring and initializing a local variable:
int i = 0;
while (i < 10)
When using a loop counter, it is important to remember to advance the counter to the next value in the body of the loop. For instance, to log the numbers 0 through 9:
int i = 0;
while (i < 10) {
  NSLog(@"%d", i);
  i++; /* advance the loop counter */
}
If you forget to advance the loop counter, you will create an infinite loop.
int i = 0;
/* warning, infinite loop, i is always 0 */
while (i < 10) {
  NSLog(@"%d", i);
  /* oops, forgot to increment i */
}
The while loop is frequently used when iterating over a stream or sequence of unknown size where a loop counter is unnecessary. For instance, to iterate over a null-terminated string by incrementing the string pointer:
char const *s = "foobar";
while (*s) {        /* while current character isn't zero */
  NSLog(@"%c", *s); /* log the current character */
  s++;              /* increment address in s to next character */
}
Similarly, the idiomatic way to read characters from a standard C FILE is:
FILE *file = /* open file for reading ... */;
int ch;
while ( (ch = fgetc(file)) != EOF) {
  NSLog(@"%c", ch);
}
The loop condition ( (ch = fgetc(file)) != EOF) in this idiom does three things:
  1. fgetc(file) gets the current character and advances to the next
  2. (ch = fgetc(file)) assigns the current character to ch
  3. (ch = ...) != EOF checks that the value of ch is not EOF
Next time, we will look at the do...while loop.

Friday, October 23, 2009

iPhone Friday - October 23, 2009

Hello and happy Friday.  Today's collection of iPhone and iPod touch wallpapers are from a two part series entitled Bubble Series A.  Today we have part one - five pictures of bubbles taken at night.  Enjoy.










Wednesday, October 21, 2009

Dear Palm, it's just not working out.

Jamie Zawinski has recently been writing about his travails trying to publish some open source applications for the Palm Pre. As iPhone developers who have to deal with Apple's often opaque and sometimes arbitrary approval process, we certainly sympathize.

On Monday he publicly declared that he's giving up on the Pre and buying an iPhone. And his beef is not with Palm's app approval process, but with the Pre itself:
Believe it or not, this actually has nothing to do with my utterly nightmarish experience of trying to get my applications into Palm's app catalog, and everything to do with the fact that the phone is just a constant pain to use.
He goes on to praise the iPhone:
and even though I absolutely despise the iPhone's on-screen keyboard... at least now I have a phone whose software actually works.
Jamie's post also inspired Steve Frank of Panic to write about his love-hate relationship with the iPhone.

Read Dear Palm, it's just not working out.

Tuesday, October 20, 2009

Objective-C Tuesdays: The for...in loop

We've looked at the standard for loop for the last two weeks. This week we will dive into the for...in loop introduced in Objective-C 2.0. Unlike the standard for loop, the for...in loop is not available in plain old C.

In Objective-C, collection classes such as NSArray, NSSet and NSDictionary are a key part of the Objective-C Foundation framework. Collections provide high level ways to group and organize objects.

In older versions of Objective-C, looping over items in a collection is done using an NSEnumerator object in a while loop:
NSSet *items = [NSSet setWithObjects:@"foo", @"bar", nil];
NSEnumerator *enumerator = [items objectEnumerator];
NSString *item = nil;
while (item = [enumerator nextObject]) {
  // do something with item
}
It's possible to loop over items in a NSArray using a standard for loop, since NSArray has a well defined order:
NSArray *items = [NSArray arrayWithObjects:@"foo", @"bar", nil];
for (NSUInteger i = 0; i < [items count]; i++) {
  NSString *item = [items objectAtIndex:i];
  // do something with item
}
Unfortunately, some collection classes (such as NSSet) don't have a well defined order; NSEnumerator used to be the only option.

The for...in loop works on any collection that conforms to the NSFastEnumeration protocol (all the standard ones do). The for...in loop is similar to a standard for loop but simpler. Instead of the three sections of a standard for loop, there are two, the loop variable and the collection expression:
for (loop variable in collection expression) {
  // do something with loop variable
}
Loop Variable The loop variable can be a previous declared variable:
NSString *item = nil;
// ...
for (item in collection expression) {
  // do something with item
}
or it can be declared inside the parentheses:
for (NSString *item in collection expression) {
  // do something with item
}
Collection Expression The collection expression can be any expression that evaluates to an object conforming to NSFastEnumeration. Typically, this is simply a collection variable defined elsewhere:
NSSet *items = [NSSet setWithObjects:@"foo", @"bar", nil];
// ...
for (NSString *item in items) {
  // do something with item
}
but can be a function call or method call:
for (NSString *item in [NSSet setWithObjects:@"foo", @"bar", nil]) {
  // do something with item
}
Dictionaries When using a for...in loop with a NSDictionary, the loop variable receives the dictionary keys; to work with the dictionary values inside the loop, use objectForKey:
NSDictionary *numbers = [NSDictionary dictionaryWithObjectsAndKeys:
    @"zero", @"0", 
    @"one", @"1", 
    nil];
for (NSString *key in numbers) {
  NSString *value = [numbers objectForKey:key];
  // do something with key and value
}
Mutation Guard Modifying a collection while iterating over it can cause very unintuitive behavior, so the for...in loop uses a mutation guard behind the scenes. If items are added or removed from a collection while your for...in loop is running, an exception is thrown. This is generally a good thing, but it makes filtering a collection somewhat tricky:
NSMutableSet *items = [NSMutableSet setWithObjects:@"", @"a", @"aa", @"aaa", nil];
for (NSString *item in items) {
  if (item.length < 2) {
    [items removeObject:item]; // WARNING: exception thrown on mutation
  }
}
The way to get around this restriction is to iterate over a copy of the collection and modify the original (or vice versa):
NSMutableSet *items = [NSMutableSet setWithObjects:@"", @"a", @"aa", @"aaa", nil];
for (NSString *item in [[items copy] autorelease]) {
  if (item.length < 2) {
    [items removeObject:item]; // OKAY: looping over copy, changing original
  }
}
Next week, we will look at the while loop.

Monday, October 19, 2009

Orchard's Craps - Preview Video

We have a "preview" video of Orchard's Craps available for you to view here or on our Able Pear YouTube Channel.  There are review and walk-though videos coming soon... stay tuned...



Orchard's Craps is available at the App Store for the iPhone and iPod touch and we have a FREE version of Orchard's Craps for the PC and Mac.

The two App Stores

Marco Arment, the lead developer of Tumblr, wrote a great post recently about the two different types of App Store customers and how to match your app to the type of customers you're looking to attract.
These two stores exist in completely different ecosystems with completely different requirements, priorities, and best practices.

But they’re not two different stores (“Are you getting it?”). There’s just one App Store at a casual glance, but if you misunderstand which of these segments you’re targeting, you’ll have a very hard time getting anywhere.
Read more about The two App Stores.

Friday, October 16, 2009

iPhone Friday - October 16, 2009

Hello and happy Friday. Todays set of wallpapers come from Japanese Design (Dover Pictura) which is part of a collection of books including Chinese Design and Art Deco just to name a few. I highly recommend them as they are beautiful, inspiration and (within their terms) royalty-free. Have a great weekend!








Thursday, October 15, 2009

In App Purchase now available for free apps


Apple announced today that developers can now use In App Purchases in their free apps.  This not only unlocks a new revenue stream for several existing free apps but also paves the way for a new type of "lite" version of a app.  No more downloading an app to test it only to have to download the "for pay" version.  ("One app to rule them all" - LOTR quote... really!)

Apple also says this should help combat some of the problems of software piracy by allowing you to verify In App Purchases.

To learn more, log into your Apple iPhone Developer account and visit the App Store Resource Center.

If you are a developer currently looking into using In App Purchases in your existing or upcoming fee iPhone/iPod touch app, we'd love to hear from you on your new experience.  Cheers!

App Store Heresies: Higher Price, Better Ratings.

Dan Grigsby of Mobile Orchard presents an interesting argument against discounting your app, particularly when you first launch:
Furthermore, the likelihood of a 1-star review goes up as the price goes down: 1-star ratings made up 23% of the total number of ratings in the free group; 16% in the paid group.
Read App Store Heresies: Higher Price, Better Ratings. Don’t Discount Your App At Launch.

Tuesday, October 13, 2009

Objective-C Tuesdays: for loop variations

Last week, we examined the structure of the for loop. Today we will look at some for loop idioms.

Infinite loop If you omit the initialization, condition and action expressions, you get an infinite loop:
for (;;) {
  NSLog(@":-)");
}

Missing loop expression Sometimes, there's no need to initialize a variable before looping, so the initialization expression is omitted:
char *process_line(char *buffer) {
  for ( ; *buffer != '\n'; buffer++) {
    /* do something with characters */
  }
  return buffer;
}
Similarly the condition or action expressions are sometimes omitted.

Nested loops When building or processing tables of information, put one for loop inside another:
for (int i = 1; i <= 10; i++) {
  for (int j = 1; j <= 10; j++) {
    NSLog(@"%d X %d = %d", i, j, i * j);
  }
}

Parallel iteration You can use multiple loop counter variables by using the comma (,) operator to squeeze multiple expressions into initialization and action:
int i, j;
for (i = 0, j = 9; i < 10; i++, j--) {
  destination[i] = source[j];
}

There's a gotcha with the initialization expression however: only one loop counter variable can be declared there. It seems logical to do this:
for (int i = 0, int j = 9; i < 10; i++, j--) ...
but unfortunately you can only do this:
int j;
for (int i = 0, j = 9; i < 10; i++, j--) ...

Next week, we'll look at the Objective-C 2.0 for...in loop.

Monday, October 12, 2009

Tearing down the App Store hype

Newsweek recently published an article entitled Striking It Rich: Is There An App For That?. While it's an interesting read, it's the typical post-hype tear-down article. Since the opening of the iTunes App Store, the press has relentlessly hyped the "get rich quick selling iPhone apps" story. Well, I guess the story has played out; now the tear-down begins.

It seems Newsweek has discovered that not everyone instantly strikes it rich. In fact, it takes most of us a lot of work, a bit of risk and more than a little perseverance to bootstrap a new business. And even successful iPhone developers in the hit-driven gaming segment are worried about how well their next game will sell. With a different tone, the article would actually be an interesting exposé on high tech entrepreneurship, but Newsweek writer Tony Dokoupil gives the piece an air of dejection and disillusionment.

David Barnard of App Cubby, who is featured in the article, wrote an interesting rebuttal (warning: contains a cute baby picture at the end).

iPhone developer Bjango also recently posted a rebuttal in their blog.

Friday, October 9, 2009

iPhone Friday - October 9, 2009

Hello and happy Friday.  Todays collection of iPhone/iPod touch wallpapers are inspired from the 60's, 70's and some vector art...  Enjoy!












Thursday, October 8, 2009

Picking an iPhone App Icon Color

Question: What color should your iPhone app icon be?



Answer: (click here)

Wednesday, October 7, 2009

Building iPhone Apps with HTML, CSS, and JavaScript

O'Reilly has published a pre-print HTML version of the book Building iPhone Apps with HTML, CSS, and JavaScript by Jonathan Stark.

Building iPhone Apps with HTML, CSS, and JavaScript covers web apps vs. native apps for iPhone, styling HTML for the iPhone, animation, client-side data storage and offline application caching.

This book looks like it's going to be a valuable resource for both iPhone SDK app creators and web developers who want to target iPhone users.

Tuesday, October 6, 2009

Objective-C Tuesdays: The for loop

Welcome to the first episode of Objective-C Tuesdays. We'll be focusing on C and Objective-C basics. Today we will look at the standard C language for loop.

The for loop is the most flexible looping statement in C, and the most common. It groups all the important loop information together at the start of the loop, making it quick and easy to both read and write.

The for loop statement starts with the keyword for, followed by parentheses containing the loop definition. The loop definition contains three expressions separated by semicolons: initialization, condition and action. After the parentheses, a single statement or block makes up the body of the loop.
/* for loop with a single statement */
for (initialization; condition; action) statement;

/* for loop with a block */
for (initialization; condition; action)
{
  block;
}
Watch out for a hard to spot bug when the for loop is followed by an empty statement created by an extra semicolon:
for (initialization; condition; action); /* <-- warning! empty statement! */
{
  /* this block is not part of the loop */
  /* it's always executed exactly once  */
}

Initialization The initialization expression is where the starting value of the loop counter variable is set. The initialization expression is evaluated once before the for loop begins executing. Loop counters are commonly integer types, but can be any type that makes sense in your code. In modern versions of C and Objective-C, the loop counter can be declared in the initialization section as well. The loop counter is typically given the name i (or j or k in nested loops). In C99 and later, initialization looks like:
for (int i = 0; condition; action)
In older versions of C, the loop counter must be declared somewhere before the for loop:
int i;
/* ... */
for (i = 0; condition; action)

Condition The condition expression is evaluated before each iteration; the loop continues while the condition evaluates to true or non-zero and stops when the condition evaluates to false or zero. The condition expression is often a "less than" (<) or "less than or equal to" (<=) expression:
for (int i = 0; i < 10; action)
or
for (int i = 1; i <= 10; action)
but it can be any expression that makes sense in your code.

Action The action expression is evaluated at the end of each iteration, after the condition and the body of the loop are executed. The action is typically used to increment or decrement the loop counter, but can be used to perform any action that makes sense for your code. Most of the time, you simply want to increment the counter by one:
for (int i = 0; i < 10; i++)
but other increments are easy to do:
for (int i = 0; i < 10; i += 2)

Example Putting this all together, here's some Objective-C code to count from 0 to 5 and back to zero:
for (int i = 0; i <= 5; i++) {
  NSLog(@"%i", i);
}
for (int i = 4; i >= 0; i--) {
  NSLog(@"%i", i);
}
The output looks like this:
0
1
2
3
4
5
4
3
2
1
0

Next week, we'll look at some of the crazy and complicated ways you can use the for loop.

Monday, October 5, 2009

Orchard's Craps now available in the iTunes App Store

Able Pear is very happy to announce that our latest application, Orchard's Craps, is now available in the iTunes App Store.

Orchard's Craps is an iPhone and iPod touch version of the classic casino dice game and is the first of in the Orchard's Casino series of games.

Orchard's Craps features include:
  • Animated 3D dice with sound
  • Real stickman calls for rolls
  • Horn and Hard Ways bets
  • Adjustable minimum bet, maximum bet and pass line odds
  • Standard casino craps table rules
In addition, we will be releasing free Mac and Windows versions of Orchard's Craps very soon.  The Mac and Windows versions feature the same gameplay as the iPhone version so you can try Orchard's Craps out before you buy, or play on the big screen at home and your iPhone or iPod touch on the go.

We hope you enjoy playing Orchard's Craps as much as we enjoyed creating it!

Click here to see our complete list of apps.

Friday, October 2, 2009

iPhone Friday - October 2, 2009

It's Friday, and with it comes new iPhone and iPod touch wallpapers.  This week is the third installment of the Hubble Space Telescope set (links after images).