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







Wednesday, September 30, 2009

Game Strategy, Development & Design for iPhone & mobile app

Come join us tonight at 6 PM at Hurricane Electric in Fremont for Alice in Wonderland: Game Strategy, Development & Design for iPhone & mobile app, an event sponsored by Silicon Valley Web Builder.

Panelists from PlayMesh, Slidetoplay.com, Team4000 Software and Redbot Software will discuss iPhone game development, marketing strategies and working with Apple and the App Store. We hope to see you there!

Tuesday, September 29, 2009

The Pains of iPhone Ad Hoc Beta Testing

The guys at Broadersheet talks about the pain of distributing a pre-release version of an iPhone app to beta testers using ad hoc distribution in their recent blog post.

We feel your pain here at Able Pear. :-)  Working with far flung beta testers and consulting clients and walking them through the ad hoc process is one of the least fun parts of iPhone development.

Monday, September 28, 2009

Apple's App Store: 85,000 apps and more than 2,000,000,000 downloads

Today Apple announced that more than two billion apps have been downloaded form the App Store.  There are now more than 85,000 apps available in the App Store with more than 50 million iPhone and iPod touch customers world wide.
"The App Store has reinvented what you can do with a mobile handheld device, and our users are clearly loving it," said Steve Jobs, Apple's CEO
Looking at the numbers I see some interesting things such as there are now 85,000 apps in the store and 125,000 developers in Apple's iPhone Developer Program...  So that's each developer  publishing .68th of an app!?  No.  I know that there are several developers working on one app.  For us there are two developers and when you include our clients there's a few more - they don't develop the app, but they do need to retain ownership of the product and it requires participation in the program.

Also, with two billion apps downloaded of the 85,000 apps available that's about 23,530 downloads per app... (ah, if that was only the case.)

Friday, September 25, 2009

Apple enters game space - console and game makers worry

In a recent article written by Hiroko Tabuchi (twitter) of the New York Times, Hiroko talks about the Tokyo Game Show going on this week/weekend and how industry executives are worried about Apples push into the handheld game market with it's iPhone and newly beefed-up iPod touch.

As Able Pear Software develops several applications with several in the game space I found this article to be interesting and insightful. I didn't realize the impact the iPhone and iPod touch with it's App Store was making in the console game industry. But with games as little as .99 cents or free I can see where they would be worried about their $30.00 and up titles and declining hardware sales.