are on the course of unabated popularity, despite the heavy competition from close quarters, the demand for Apple devices continues to grow at a breathtaking rate. And due to this growing traction towards these devices, there are individuals taking up iOS
programming to catch this wagon that holds great promises for their careers.
But all said and done, it is no hidden fact that iOS tools and technologies keep reinventing themselves and it’s only about time a newer version will be launched to make the current one obsolete. And that’s where many developers find it hard to catch up. Those who are used to working on the current versions of tools find it hard to adapt to the newer one. And Xcode falls in the same category as well.
The developers who have been working on a particular version of Xcode are not comfortable working with the newer version as it brings several new features and complications that are not comprehensible to the folks already expert at the current version.
Now, if you are a coder who wishes to create, let’s say, Xcode 4.0 style application using the Xcode 4.2, the process is very much possible. And this is how you do it:
Converting a new Empty Application into a Window-based Application
Being an iPhone App Programmer, in order to begin with, you need to create an altogether new project, and you do so by creating the “Empty Application” project. As soon as you create this project, a new “Window-based Application” project will also be created cardinally, only with a bunch of dissimilarities:
- As the main controller class gets initiated, it gets initiated as “AppDelegate”. What you could have expected rather was it to be created as “<project-name>AppDelegate”.
- You won’t be able to find the XIB view.
- If you carefully observe with window property of AppDelegate, you will not notice any IBOutlet macro. As a result of this, it can’t be seen from the Interface Builder tooling.
Now, Let the Controller be Prepared for Communicating with the Interface Builder Tooling
This is an indispensable step where tooling has to be made capacitated to identify the controller. And this is accomplished by adding the IBOutlet macro. To do so, you will need to play around with the controller header file. This is how you do it:
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) IBOutlet UIWindow *window;
As soon as you make the necessary modifications, save all the changes.
Next Stop: Updating the didFinishLaunchingWithOptions: method
The first line of the didFinishLaunchingWithOptions: method doesn’t allow seamless message communication. You need to comment the same:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
//self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
Now, Creating the XIB File Follows
Go to the folder that hosts the AppDelegate files and right-click on it. Now go for “Add File”. The new window you have will require you to select “Window”. Choose iPhone as the device family. Here, you get a default name for the file and it is Window.xib:
Changing the Class of the XIB file’s owner Follows
Now that you are in the Navigator, you need to select Window.xib. From there, you must go for “File’s Owner”. And then, the class has to be changed to UIApplication.
Controller Has to Be Equipped with an Object
Now, select the “Objects and Controllers” setting on the tool menu and following that, you will have to place the Object on the object pane through the drag and drop procedure.
Determine the Class
Now, the controller that was generated in lieu to your project, the class has to be set to that particular Controller.
XIB delegate has to be sent across to the controller
The MVC message routing has to be made more connective, or which, you need to select the “File’s Owner” cube in the object pane. Now, proceeding further, control+drag the delegate outlet to the App Delegate object.
Controller object’s window outlet has to be sent to to the window object
Now, again go for the ctrl+drag of the window outlet from the App Delegate object, and this time, to the Window object. And thus, following the above process, you can efficiently create a Xcode application on 4.2 version modelled on the 4.0 platform.