Developing on the iPad – What Does Code Look Like?

28 Jun 2010 | iPad Development |

If you have made it this far, you are probably serious about starting to develop iPad apps, and we wish you every success in your endeavors.

ipad-apple-tablet

As we have already indicated, you should buy yourself some beginners guides to programming and join some development forums ask questions and start to get a feel for what OOP programming is all about.

But what about the code what does this look like?

One of the first things you will learn is to be organized. If your code is messy, you will get to a stage where even you don’t know what is going on! The key to organisation is Commenting.

Commenting is where you enter some text into the code itself so you explain and remember what this particular bit does. This will make debugging and tracking back so much easier further down the line.

Commenting in code looks like this:

/* Code Comments:** Example written by iPADs House** This is an example of commenting** It serves no purpose other than as a way to remind you what** this part does

** It will never be run by the application, but never forget comments

*/

So now you have seen what a section of commenting looks like. You must always remember to include the /* and the beginning and */ at the end as these are parameters that the compiler understands to ignore and do nothing with.

There is another way of commenting your code and this is by adding to the end of a line. The container above will server a purpose for more detailed instruction, but if you wanted to just explained what one line did, it would look like this:

#include <objc/Object.g>  // Includes the gcc Object.g header file

In this example, you will see that the method used is different and adds two slashes // to the end of that particular line. Once again, the compiler will know not to do anything pas the // comments.

But we urge you not to worry too much or think that this is going to be beyond your capabilities, because it won’t be. Objective-C contains SmallTalk; this essentially means that commands are more descriptive, allowing for a much quicker learning curve than many other languages.

Don’t worry too much about what this Class Header file is or what it does, but you will see what we mean when we say it is more descriptive:

#import <W3Kit/W3PostScript.h>

@interface DotView:W3PostScript

{

Point2 dot_position;

float dot_radius;

}

- (float)dotRadius;

- setDotRadius:(float)r;

- takeDotRadiusFrom:sender;

@end

See how the code seems to read more like a sentence?

We hope that you now venture on the exciting journey of programming in Objective-C and look forward to reviewing your apps at some point in the future!

 

You might also like to read:

iPad’s Developer Problem

iPad Site Testing with Safari

Steps to Quality iPad Application Development

So You Want to Become an iPad Application Developer? Introduction

iPad App Development: Developing a Good Human Interface