Posts

MapView programe in iPhone

Image
1. Create a new project (ViewBased application ) 2. Import the MapKit in header file... #import <MapKit/MapKit.h>  also add the MapKit.framework under resources folder from the existing frameworks. 3. In the same viewController's header file call the <MKMapViewDelegate> and define the MKMapView *myMapView; synthesize and release the myMapView object into implementation file. 4. In a viewcontroller.xib file ..add the map view on UIView and connect it with corresponding object in file owner. Further see the code given below…. Header #import <UIKit/UIKit.h> #import <MapKit/MapKit.h> @interface myMapViewController : UIViewController <MKMapViewDelegate> { IBOutlet MKMapView* myMapView; } @property (nonatomic, retain) IBOutlet MKMapView* myMapView; -(void)displayMYMap; @end Implementation #import "myMapViewController.h" @implementation myMapViewController @synthesize myMapView; // Implement view...

How to create Hello world programe in iPhone?

Image
To start, launch Xcode and create a new project by going to File > New Project.  Under the iPhone OS section of the New Project window select View-Based Application. You should be presented with the following window: Creating the UI We’re going to start with creating the UI.  iPhone applications use files called xib or nib files to help separate the coding from the design.  To open the default xib file select the Resources folder on the left menu, and open HelloWorldViewController.xib.  This should open Interface Builder. What we want to do is create the interface for our HelloWorld! application.  To start go to Tools > Library, which should open up the Library of all the different UI elements you can  use.       In your HelloWorldViewController.xib window double click the View object to open up the view.  This is what your application will look like when you load it.  What we want to do here is...

Delegation in iPhone SDk

Image
Delegation allows an object to pass the responsibility for performing one or more tasks on to another object. This allows the behavior of an object to be modified without having to go through the process of subclassing it. A prime example of delegation can be seen in the case of the UIApplication class. The UIApplication class, of which every iOS iPhone application must have one (and only one) instance, is responsible for the control and operation of the application within the iOS environment. Much of what the UIApplication object does happens in the background. There are, however, instances where it gives us the opportunity to include our own functionality into the mix. UIApplication allows us to do this by delegating some methods to us. As an example, UIApplication delegates the applicationDidFinishLaunching method to us so that we can write code to perform specific tasks when the app first loads (for example taking the user back the point they were at when they last exited). If y...

Model View Controller (MVC)

Image
In the days before object-oriented programming (and even for a time after object-oriented programming became popular) there was a tendency to  develop applications  where the code for the user interface was tied tightly to the code containing the application logic and data handling. This coupling made application code difficult to maintain and locked the application to a single user interface. If, for example, an application written for Microsoft Windows needed to be migrated to Mac OS, all the code written specifically for the Windows UI toolkits had to be ripped out from amongst the data and logic code and replaced with the Mac OS equivalent. If the application then needed to be turned into a web based solution, the process would have to be repeated again. Attempts to achieve this feat were usually found to be prohibitively expensive and ultimately ended up with the applications being completely re-written each time a new platform needed to be targeted. The goal of t...

Core data for iPhone SDk

Image
Core Data helps you to save model objects (in the sense of the model-view-controller design pattern) to a file and get them back again. This is similar to archiving technology but Core Data offers much more than that. Amongst other things it… ·          Provides an infrastructure for managing all the changes to your model objects. This gives you automatic support for undo and redo, and for maintaining reciprocal relationships between objects. ·          Allows you to keep just a subset of your model objects in memory at any given time. This is especially important on iPhone where conserving memory is critical. ·          Uses a schema to describe the model objects. You define the principal features of your model classes—including the relationships between them—in a GUI-based editor. This provides a wealth of basic functionality “for free,” including setting of...

Creating a custom Table View Cell programmatically

Image
First thing we will do is create a customCell. Right click on Classes and add a new UITableViewCell subclass. Name it as “CustomCell”. Now open CustomCell.h and add the following code: #import @interface CustomCell : UITableViewCell {   UILabel * primaryLabel ;   UILabel * secondaryLabel ;   UIImageView *myImageView; } @property ( nonatomic , retain ) UILabel * primaryLabel ; @property ( nonatomic , retain ) UILabel * secondaryLabel ; @property ( nonatomic , retain ) UIImageView *myImageView; @end We create the three elements and added them to the contentView of our cell. synthesize all the three elements in CustomCell.m as we are going to access these elements from other classes. @synthesize primaryLabel,secondaryLabel,myImageView; Here we have simply added a primary label to display the primary text, a secondary label and an imageView. These elements will be created and added into the content view of our custom cell. So open Cust...