There are no active ads.

Advertisement

Introduction to iOS Development: Building a Functional Web Browser

How do you develop apps for iOS?  It’s a common question that many computer enthusiasts ask, and one we here at TechnoBuffalo hope to answer with this series of posts.

Learning how to develop software can be one of the most intimidating prospects for the average computer user, and with the growing saturation of applications in mobile marketplaces, it is becoming increasingly difficult to get your work noticed. That’s what this series is for, helping you learn iOS development from a conceptual perspective. No prior knowledge of computer programming will be necessary. Over the coming weeks, we’ll examine the iPhone’s ability to deliver immersive, intuitive content, a unique opportunity for both developers and consumers.

Today, we’ll be utilizing Apple’s WebKit framework to create a functional browser. As imitation is the greatest form of flattery, the interface of the application will resemble that of Safari.

1. First, we must open up Xcode 4, Apple’s latest Integrated Development Environment. Select New Project and follow the on-screen prompts until you are met with the template page. Select Window-based Application and make sure that you are targeting the iPhone.

2.  After following Xcode’s instructions on setting up the application, entitle the program Browser and save the file in a convenient place, preferably one that can be easily remembered and accessed in the future.

3.  Today, we’ll only need to manipulate the project’s App Delegate. Head on over to the initialization file (BrowserAppDelegate.h) and begin to add some of the code below. You’ll notice that we are creating IBOutlets, or Interface Builder Outlets, which are creating the code for variables that we will use later.

————————————————————————————-

@interface BrowserAppDelegate : NSObject <UIApplicationDelegate> {

UIWindow *window;
IBOutlet UIWebView *web;

}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

————————————————————————————-

4.  Head on over to the implementation file, which tells the program how to react to the variables we created earlier. Using the code below as a point of reference, ensure that the method described looks exactly as written. It will tell the window where to go.

————————————————————————————-

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

[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@”https://www.technobuffalo.com/”]]];

[self.window makeKeyAndVisible];
return YES;
}

————————————————————————————-

5.  We now get to play around with the interface of the program. Head on over to MainWindow.xib and drag in a toolbar. Place four buttons onto the bar. Define them in the attributes of the various objects. Last, but certainly not least, drag the WebView into the window.

6.  Go to the interface outlets and ensure that all of your elements are connected as follows:

7.  Build and run your application! It should take you to TechnoBuffalo’s homepage, giving you the ability to read articles and catch up on your favorite series, Introduction to iOS Development.

Questions?

If you have any questions about the topics discussed in this lesson, feel free to voice them in the comments below. We will do our best to ensure that you have a relatively painless experience developing for iOS. Stay tuned for the next installment of this series, which is released weekly.

To read previous installments from this series, check the links below.