Month: October 2012

Iphone development from the view of an Android Developer

Posted on Updated on

Well, it’s been long that I have published posts in here. Things happen when people are engaged in other work or maybe not having time to manage things or being lazy all time whatever. Ok anyways this time I have come up with an interesting topic which may give some idea on how iphone programming is similar to android.  

First of all let’s start with the application structure of both the platforms

 (Iphone Project Files )                                                                                                                                             (Android Project Files)

When you first create an iphone project in XCODE the following default directories are created

  • Classes: Contains the class files required for the project (Same as src folder in android). The class files are of three types
    • .h file: Header file
    • .m file: Objective-C source file
    • .xib file: Interface Builder file (Same as the XML layout file found in the res->layout folder in android project)
    • Other Sources: Contains the main file required for the project. The app starts by executing the main file.
    • Resources: Contains the resources required for the project such as Image, Sound, Video etc (Same as the res and asset folder in android).
    • Frameworks: Contains the package required for the project (Same as lib file in android)
    • Products: Contains the final compiled app ending with extension .app whereas for android the final product name ends with .apk extension(Same as the apk file generated in bin folder of android project)

Android project contains a file named “AndroidManifest.xml” which forms the skeleton of an android app. It contains information about the SDK version, permissions, Class names, app version etc. In an iphone app there is no such file named manifest. Instead all the above said parameters are defined in a neatly but complicated user interface known as BUILD SETTINGS.


Now let’s discuss about the application life cycle in both the platforms because life cycle methods defines how the application should behave according to various conditions. In iphone project two files are created along with the class files known as ClassnameAppDelegate.h and the corresponding counterpart .m file. The app delegate has two roles in here, it defines the various lifecycle of an app and also acts as the Application object class same how we declare variables and getter/setter methods in android application class. The various lifecycle methods defined in iphone appdelegate class are

•             – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

•             – (void)applicationWillResignActive:(UIApplication *)application : Same as onRestart() in android

•             – (void)applicationDidEnterBackground:(UIApplication *)application: Same as onPause() in android

•             – (void)applicationWillEnterForeground:(UIApplication *)application: Same as onResume() in android

•             – (void)applicationDidBecomeActive:(UIApplication *)application: Same as onStart() in android

•             – (void)applicationWillTerminate:(UIApplication *)application: Same as onDestroy() in android

Other similarities as of development scenario. Both the OSes have excellent IDEs and SDKs for development with rich in features and the appropriate emulators and simulators. When the variable declaration and coding style comes both the programming languages differs a lot. Objective-C is actually a highly customized C programming language. In fact apple might have developed such a customized language so that it won’t hamper the smooth functioning of iphone nor to cause any memory overflow or CPU load.  Now in the case of declaring variables and methods iphone uses datatypes declared in Foundation class (jus google out regarding Foundation class too lazy to explain thats why J ). For example for declaring a String variable we use “NSString *variable;

Now defining a method the syntax in Java is “functionName(String  value);” but as of Objective-C the syntax is [self functionName:NSString *value];

Now regarding access specifiers. In java we use private, public and protected. In objective-C we use the same notations except for @ symbol as prefix i.e, @public, @private and @protected.

If we say about exception handling Objective-C applies the same syntax as that of java. i.e,

//some code
//catch block
//finally exececute some code

Another similarity is the use of “this” pointer. In Objective-C the “this” pointer is declared as “self” and every overriden methods in java are defined in delegates in objective-c. Say for example if you have ListView in android and the ListView will have set of predefined overridden methods similarly in the case of iphone say for example the overridden methods for a Tableview are defined in their corresponding delegates.

One more important factor to be considered while programming in iphone. Iphone doesn’t have automatic garbage collection technique. So this means whatever variable you have declared should be released after use otherwise beware of MEMORY OVERFLOW.

Hope my little briefing might have helped you in understanding the similarities and differences in both the platforms in some way or the other. So keeping visiting my blog  for more updates. Happy coding!!