Home and Blog button

Pages

Introduction

Welcome To my Blog !!
This is a blog where you can get some knowledge that i have learned and been using. Sharing is gaining pals. So Happy Sharing and don't forget to follow and link my blog with yours! Thanks.
Happy Programming!!

Thursday, January 27, 2011

How to Begin Iphone Programming ?

Objective C is a programming language used by apple to create an iphone applications and games (You can also use C++, which we will discuss later). Most of programmers who program in Windows environment may not even heard about Objective C language, whereas Mac users and Linux users would be familiar with this term.

To do programming any language we need an IDE. For example we do C# in Visual Studio IDE, Java in NetBeans, Eclipse etc. In a similar manner, the objective C language is performed in Xcode which is IDE for Objective C language. I have already mentioned about it a bit in my previous "Update on the Blog" post.

But the best practice or say the only easy option is to buy Mac, install Xcode and do iphone programming in order to sell your app without any further issues in appstore.

To start iphone programming you need to have following materials:
  1. Object Oriented Programming Language knowledge
  2. Xcode with latest iphoneSDK (ver 4.3 beta 2 is latest)
    1. You can download iphone SDK and latest xcode at Apple Developer Site. For more information join in the iPhone Developer Program.
  3. After you download .dmg file install the Xcode.
  4. Now you are ready to go through the iPhone Programming.
Create a simple Iphone Application:


  1.  Click on File -> New Project (You will see following dialog)
  2. In iPhone OS, select Application -> Window Based Application
  3. Click on Choose -> Give Name of your project and location (default is Documents) -> Ok

Now in Classes directory you will have two files, YourProjectNameAppDelegate.h and YourProjectNameAppDelegate.m file.



The "h" is header file and is understandable if you are familiar with C and C++. And "m" file is the implementation file (similar to .cpp in C++) where you will write all your implementation code.

In Resources directory, you will find a "MainWindow.xib" file which is called "nib" file. It is the Interface builder file. You can build your program interface by directly opening this nib file using drag and drop method (Just like in VB you use drag and drop toolbox items). Or you you can also do code to create each items in interface such as textfield, buttons etc (as in  Turbo C, C++, created using co-ordinate codes).

We will deal about nib file later and ways to hooking controls coz it is the fast way to create your Interface rather than going on coding each piece of code.


Let's go to ".m" file:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
   
    // Override point for customization after application launch.
    /* --- Your code goes here --- */
    [window makeKeyAndVisible];
   
    return YES;
}

The above function is the starting function to start our app (analogous to main() function in C, C++). As you have noticed that the above defined function is different from C++ function definition syntax. It is Objection C style syntax. Let's do a little analysis.
  • "-" This starting symbol indicates that this function is a member function of "YourProjectAppDelegate" Class. If instead of "-", you see "+" this ensure that it is a static function of corresponding class (no need of object to call it). If you are C++ user you can easily understand it.
  • (BOOL) is a return type of a function. (BOOL = Boolean type)
  • "application: " It is a function name.
  • The line beyound "application:" are the arguments with corresponding arguments type. 
    I will explain about function definition later, it is where beginners feel uneasy with C++. But above method has a key advantage than using C++ argument types.

    Hope this helps, if you need any help comment it.

      1 comment:

      1. You made some decent points there. I looked on the internet for the issue and found most individuals will go along with with your website.

        ReplyDelete

      Search This Blog