Thursday, 26 July 2012

iPhone Bluetooth Programming


Creating the Project
Using Xcode, create a new View-based Application project and name it as Bluetooth.
All the various APIs for accessing the Bluetooth is located in the GameKit framework. Hence, you need to add this framework to your project. Add a new Framework to the project by right-clicking on the Frameworks group in Xcode and selecting Add, Existing Frameworks. Select GameKit.framework




In the BluetoothViewController.h file, declare the following object, outlets, and actions:

#import
#import
@interface BluetoothViewController : UIViewController {
GKSession *currentSession;
IBOutlet UITextField *txtMessage;
IBOutlet UIButton *connect;
IBOutlet UIButton *disconnect;
}
@property (nonatomic, retain) GKSession *currentSession;
@property (nonatomic, retain) UITextField *txtMessage;
@property (nonatomic, retain) UIButton *connect;
@property (nonatomic, retain) UIButton *disconnect;
-(IBAction) btnSend:(id) sender;
-(IBAction) btnConnect:(id) sender;
-(IBAction) btnDisconnect:(id) sender;
@end


The GKSession object is used to represent a session between two connected Bluetooth devices. You will make use of it to send and receive data between the two devices.
In the BluetoothViewController.m file, add in the following statements in bold:

#import "BluetoothViewController.h"
@implementation BluetoothViewController
@synthesize currentSession;
@synthesize txtMessage;
@synthesize connect;
@synthesize disconnect;


Double-click on BluetoothViewController.xib to edit it in Interface Builder. Add the following views to the View window
  • Text Field
  • Round Rect Button




Perform the following actions:
  • Control-click on the File’s Owner item and drag and drop it over the Text Field view. Select txtMessage.
  • Control-click on the File’s Owner item and drag and drop it over the Connect button. Select connect.
  • Control-click on the File’s Owner item and drag and drop it over the Disconnect button. Select disconnect.
  • Control-click on the Send button and drag and drop it over the File’s Owner item. Select btnSend:.
  • Control-click on the Connect button and drag and drop it over the File’s Owner item. Select btnConnect:.
  • Control-click on the Disconnect button and drag and drop it over the File’s Owner item. Select btnDisconnect:.
Right-click on the File’s Owner item to verify that all the connections are made correctly.




Back in Xcode, in the BluetoothViewController.m file, add in the following statements in bold:

- (void)viewDidLoad {
[connect setHidden:NO];
[disconnect setHidden:YES];
[super viewDidLoad];
}
- (void)dealloc {
[txtMessage release];
[currentSession release];
[super dealloc];
}


Searching for Peer Devices
Now that all the plumbings for the project have been done, you can now focus on the APIs for accessing other Bluetooth devices.
In the BluetoothViewController.h file, declare a GKPeerPickerController object:

#import "BluetoothViewController.h"
#import
@implementation BluetoothViewController
@synthesize currentSession;
@synthesize txtMessage;
@synthesize connect;
@synthesize disconnect;
GKPeerPickerController *picker;


The GKPeerPickerController class provides a standard UI to let your application discover and connect to another Bluetooth device. This is the easiest way to connect to another Bluetooth device.
To discover and connect to another Bluetooth device, implement the btnConnect: method as follows:

-(IBAction) btnConnect:(id) sender {
picker = [[GKPeerPickerController alloc] init];
picker.delegate = self;
picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
[connect setHidden:YES];
[disconnect setHidden:NO];
[picker show];
}

When remote Bluetooth devices are detected and the user has selected and connected to one of them, the peerPickerController:didConnectPeer:toSession: method will be called. Hence, implement this method as follows:
 
- (void)peerPickerController:(GKPeerPickerController *)picker
didConnectPeer:(NSString *)peerID
toSession:(GKSession *) session {
self.currentSession = session;
session.delegate = self;
[session setDataReceiveHandler:self withContext:nil];
picker.delegate = nil;
[picker dismiss];
[picker autorelease];
}
When the user has connected to the peer Bluetooth device, you save the GKSession object to the currentSession property. This will allow you to use the GKSession object to communicate with the remote device.
If the user cancels the Bluetooth Picker, the peerPickerControllerDidCancel: method will be called. Define this method as follows:
 
- (void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker
{
picker.delegate = nil;
[picker autorelease];
[connect setHidden:NO];
[disconnect setHidden:YES];
}


To disconnect from a connected device, use the disconnectFromAllPeers method from the GKSession object. Define the btnDisconnect: method as follows:
 
-(IBAction) btnDisconnect:(id) sender {
[self.currentSession disconnectFromAllPeers];
[self.currentSession release];
currentSession = nil;
[connect setHidden:NO];
[disconnect setHidden:YES];
}
When a device is connected or disconnected, the session:peer:didChangeState: method will be called. Implement the method as follows:
 
- (void)session:(GKSession *)session
peer:(NSString *)peerID
didChangeState:(GKPeerConnectionState)state {
switch (state)
{
case GKPeerStateConnected:
NSLog(@"connected");
break;
case GKPeerStateDisconnected:
NSLog(@"disconnected");
[self.currentSession release];
currentSession = nil;
[connect setHidden:NO];
[disconnect setHidden:YES];
break;
}
}
Handling this event will allow you to know when a connection is established, or ended. For example, when the connection is established, you might want to immediately start sending data over to the other device.




Sending Data

To send data to the connected Bluetooth device, use the sendDataToAllPeers: method of the GKSession object. The data that you send is transmitted via an NSData object; hence you are free to define your own application protocol to send any types of data (e.g. binary data such as images). Define the mySendDataToPeers: method as follows:
 
- (void) mySendDataToPeers:(NSData *) data
{
if (currentSession)
[self.currentSession sendDataToAllPeers:data
withDataMode:GKSendDataReliable
error:nil];
}
Define the btnSend: method as follows so that the text entered by the user will be sent to the remote device:
 
-(IBAction) btnSend:(id) sender
{
//---convert an NSString object to NSData---
NSData* data;
NSString *str = [NSString stringWithString:txtMessage.text];
data = [str dataUsingEncoding: NSASCIIStringEncoding];
[self mySendDataToPeers:data];
}

Receiving Data





When data is received from the other device, the receiveData:fromPeer:inSession:context: method will be called. Implement this method as follows:
 
- (void) receiveData:(NSData *)data
fromPeer:(NSString *)peer
inSession:(GKSession *)session
context:(void *)context {
//---convert the NSData to NSString---
NSString* str;
str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Data received"
message:str
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
Here, the received data is in the NSData format. To display it using the UIAlertView class, you need to convert it to an NSString object.

Testing the Application



That’s it!
You are now ready to test the application. Press Command-R in Xcode to deploy the application onto two iPhones / iPod Touches. For this article, I assume you have two devices -- either iPhones or iPod Touches. In order to run this application,  they both need to run at least iPhone OS 3.0.
Once the application is deployed to the two devices, launch the application on both devices. On each device, tap the Connect button. The GKPeerPickerController will display the standard UI to discover other devices .
After a while, both application should be able to find each other  When you tap on the name of the found device, the application will attempt to connect to it.

Tuesday, 3 July 2012

Submitting iPhone Apps To The Apple App Store

Step 1:

Certificate is an essential element to submit or test an application on iPhone. It comes with code sign(Signatures) which would verified when an application is submitted on apple store or when tested on iPhone.
One can bypass these if an application is installed on jail-break iPhone or  when submitted on Cydia but this is not possible when one wants submit it to AppStore.


One has to through 2 step procedure to create a certificate from developer portal. I copied those two from “iPhone developer portal”
  •  Generating Certificate Signing Request
  •  Submitting a Certificate Signing Request for Approval
Generating a Certificate Signing Request:
  •  Open the Utilities folder and launch Key chain Access from the Applications folder.
  • Set the value of Online Certificate Status Protocol (OCSP) and Certificate Revocation List (CRL) to “off” in the Preferences Menu.
  • Select Key chain Access -> Certificate Assistant -> Request a Certificate from a Certificate Authority.
  • Fill in your email address in User Email Address Field. Confirm that this email address is same as provided at the time of registering as iPhone developer.
  • Fill in your name in the Common Name field. Confirm that this name is same as provided at the time of registering as iPhone developer.
  • It is not necessary to have an Certificate Authority (CA). The ‘Required’ message would be eliminated after finishing the following step.
  • Click the ‘save to disk’ radio button if prompted, choose ‘Let me specify key pair information’ and proceed.
  •  If  you choose ‘Let me specify key pair’ option then one has provide a file name and click ‘Save’. Select ‘2048 bits’ for Key Size and ‘RSA’ for the algorithm in next screen and proceed.
  • CSR file would created on the desktop by Certificate Authority.
Submitting a Certificate Signing Request for Approval:
  •  Once CSR file is created log in to the iPhone developer program portal and go to ‘Certificates’> ‘Development’ and select ‘Add Certificate’.
  • Click the ‘Choose file’ button, select your CSR and click ‘Submit’. The portal will reject the CSR if Key Size is not set to 2048 bit at the time of CSR creation.
  • This will followed by notification to Team Admins by email of the certificate request.
  •  The change in the certificate status would informed by email on approval or rejection of the CSR by Team Admin.
Download/Installing Certificate on your machine
  • Once the CSR is approved the Team Members and Team Admins can download their certificates via the ‘Certification’ section of the Program Portal.  Choose ‘Download’ next to the certificate name to download your iPhone development certificate to your local machine.
  •  Once this is done double-click the .cer file to launch Key chain Access and install your certificate.
            On installation of certificate on your MAC the next step is to create an App ID.


 Step 2:

Follow the following steps to create an App ID:
  • Go to ‘App IDs’ and click ‘App ID’ after logging in to iPhone developer program portal.
  •  Populate the ‘App Id Name’ field with your application name (that is – iPhone app) and in ‘App Id’ enter something like com.yourdomain.applicationname (i.e com.companyname.iPhoneapp) and click submit.
  •  Please do note down the “App Id” as this would be utilized in Info.plist, bundle identifier tag.
 Step 3:

Next step would be to create a Provisioning file for our X code and is the last step for creating binary which would submit it to App Store.
  • After you navigate to ‘Provisioning’> ‘Distribution’ click ‘Add Profile’ in iPhone developer program portal.
  • Choose “App Store” in “Distribution Method”.
  •  In “Profile Name” enter your application name (i.e iPhone app) which will be your provisioning profile name as well.
  • In “App ID” select the app name(i.e. iPhone app) which you created in Step 2.
  • After downloading the Provisioning profile copy it to your/YourUserName/Library/MobileDevice/Provisioning Profile.
Step 4:

Now everything is step up, open your project in Xcode
  •  Click “i” Info button after selecting your project from “Group & File” in left side bar.
  • Navigate to “Configuration” tab and select “Release”. Click the “Duplicate” button from bottom, name is “iPhone Distribution”.
  • Click on “Build” tab and choose “iPhone Distribution” and enter in “Search in Build Settings” filed ‘Base SDK’ and select the current selected Device and  change to what gadget your application is targeting.
  • Now in “Search in build setting” field enter “code signing identity” and choose the provisioning profile created earlier in Step 3. Apply the same to the child property “Any iPhone OS Device”.
  • Once this done close the Info screen and select the “Target”> “Your App” from “Group & File” in left side bar and click on “Info” button again from X code.
  •  To be on the safer side repeat step 3 and 4.
  • With the Info screen still open click on “Properties” tab and enter “App Id”(i.e. com.companyname.iPhoneapp) in Identifier field.
  • Now that all is done, click on “Build” (cmd+B) from X code>Build.
  • You will find your binary file created on right clicking on “Product”> “YourApp” and selecting “Reveal in Finder”. Zip this file.
Step 5:

The next step is to submit the binary file created to iTunes connect.
  • In your browser type https://itunesconnect.apple.com/  and login using your iPhone developer account.
  • Click on “Manage Your Account” > “Add Application”
  • On replying to a simple question from apple you can submit your application to app store. You also need few things in your system before you submit your application.
a) Application Name (must be unique)
b) Application description
c) Application Category
d) URL for your application feedback.
e) Icon of your application in 512 x 512 size.
f) Main picture of your application in 320 x 480 or 320 x 460 size.
(You have option to submit up to 4  more pictures of your application).
 
 

Thursday, 21 June 2012

Memory Management


Memory management is more critical on handheld devices as they have very less memory as compared to desktop systems

Memory crunch can cause an application to crash, can also put device to hang.Most of the languages comes with a garbage collector which collects memory which is unused, and put back as a reusable chunk of memory.
Example: Java has a inbuilt garbage collector. which cleans up the unused variables and objects.


In iPhone a programmer has to do the task of garbage collector ie cleaning of unused variables, objects.If unused objects are not cleaned then the program will starting leaking memory and eventually cause the application to crash.
Few concepts to keep in mind while doing memory management
  •  Object Ownership
  •  Initializing Object
  •  Releasing Object
  •  Retaining Object
In iPhone memory management is done on the basis of reference counting.Reference count is defined as the number of reference to an Object.An object is free for garbage collection when the reference count is 0 for that object.

Memory management works:
  • retainCount  property of NSObject  class.
  • Keeps track of references for an object.
  • release and retain methods of NSObject class helps in memory management.
Fundamental Rules:
  
 John takes ownership of an object if John creates it using a method whose name begins with “alloc” or “new” or contains “copy” (for example,alloc, newObject, or mutableCopy), or if John sends it a retain message.
  Example: MyClass *c=[[MyClass alloc] init];

  • Every Object has a retain Count.
  • Code maintains the retain count.
  • When retain count reaches 0, Objective C deletes the object.
  • Alloc, retain, new , copy methods increase the object’s retainCount by 1.
Example:
[xObj alloc]// retain count increased by 1
[xObj retain] // retain count increased by 1

  • release and autorelease decrease the retain count by 1.
Example:
[xObj release] // decreases the retain count by 1
[yObj autorelease] // decreases the retain count by 1 at some point of time in future

Steps:

MyClass *myClass=[[MyClass alloc] init];
retainCount =1
  • [myClass retain];
         retainCount=2

  • [myClass release];
    // decrease the retain count by 1
  • [myClass release];
    // decrease the retain count by 1      
     retainCount is 0 now.
  • [myClass release]; // crash
Rule of Thumb:
  • If you create an object, make sure you release it.
  • Balance the retainCount by retain and release methods.
Autorelease Pool:

  • In this memory management happens automatically.
  • Facilitates releasing the objects that het passed around from method to method.   
  •  List of objects to send release message later in time.
  • [myClass autorelease] adds object myClass to autorelease pool
  • Autorelease pool is always emptied at the end of current event that app is processing.

Few examples:

Properties retain and release
Example:
    @property (nonatomic, retain) NSString *str;
    @synthesize str;

Generates …..?
    -(void) setStr: (NSString) *x
{
            if(x!=str)
            {
                [str release];
                str=[x retain];
            }
    }
- (NSString) str{
    return str;
    }

All this memory management is done behind the scenes.Not visible to programmer.

Other concept:

  • Dealloc also known as destructors.
  • Class doing memory management will have this method.Releases all the properties and internal state of objects.
  • Must release instance objects.
  • Have to call the dealloc of super class.
Example of dealloc:
    - (void) dealloc {
        [str release];
        [super dealloc]; 
    }
  
 [super dealloc] is required otherwise an object will never be deleted even if the retain count is 0.
  Every property and instance variable should be released in this method.

Memory Bugs

    * release to objects already deleted
        Result: crash
                Program received signal: “EXC_BAD_ACCESS”
    * forget to send release
       Result: Memory Leak
             



 

Tuesday, 29 May 2012

Storyboards

Introduction
We are all used to using view controllers now. We know how to use navigation controllers in order to push and pop view controllers. Apple believes this can be done easier and that's the whole story behind storyboards. Story boarding is the new way of defining the connection between different screens in your app. For instance, if you have 20 unique view controllers in your app which you coded a year ago, looking at the source code now you will need to find your way around the connection between these view controllers and what view controller is pushed when a certain action is taken by the user. This can be very difficult especially if you have not documented your code. Story- boards to the rescue. With storyboards, you can now view/create your entire app's UI and the connection between each view controller in one screen. It's that simple.

With storyboards, one screen's worth of content is called a scene. A scene on the iPhone can be thought of as the view of a view controller, where you put all your contents on the screen to be presented to the user at the same time. On the iPad, more than one scene can be presented to the user at the same time because of the bigger screen. Story- boarding supports transitioning from one scene to another, similar to a navigation controller pushing a view controller on top of another. That is a transition. Another type of transition is a modal view controller that slides from the bottom of the screen up to fill the screen temporarily. On the iPad, modal screens appear in the center of the screen and dim the rest of the screen usually to point out that they are the main input at that moment.

 Creating a Project with Storyboards:
  1.  In Xcode, select the File meny and then New→New Project...
  2. .In the New Project dialog, make sure iOS main category is selected and select Application sub-category under iOS. Once that is done, on the right side, select Single View Application and press Next
  3. Now select a product name and make sure your app is a Universal app.Apple wants developers to start writing universal apps whenever they can in order for iPad users to also enjoy the same apps that iPhone and iPod Touch users can enjoy. In this dialog, make sure you have checked the User Storyboards check box.
  4. You'll notice two files whose names end with .storyboard. Xcode, because this is a universal app, created a storyboard for iPhone and another storyboard for iPad
Adding a Navigation Controller to a Storyboard

Note:You want to be able to manage multiple view controllers inside a storyboard-based application.

In order to add a navigation controller to your storyboard-based app, simply follow these steps:
  1. Click on the iPhone story board that Xcode created for you.I have name demoproject Adding a Navigation Bar to a Storyboard so my iPhone storyboard file is Main- Storyboard_iPhone.storyboard. Once you click on this file, Interface Builder will display the contents of this file automatically.
  2. Once the storyboard file is open in IB (Interface Builder), simply double-click on an empty space on the storyboard's canvas and you will see the content shrink in size and give you more free space.
  3. Under the View menu, select Utilities→Show Object Library.
  4.  In the Object Library, find the Navigation Controller object and drag and drop it into the storyboard, to the left side of your existing view controller.
  5. As you can see, the navigation controller now has added another view controller to our UI. What we need to do is to simply delete this view controller by selecting it first and then pressing the Delete button on the keyboard. Now we are left with the navigation controller and our original view controller(Delete Root View).
  6. Now click once on the navigation controller object on the storyboard. Once the navigation controller object is selected, hold down the Control key on your keyboard and the left button on your mouse and drag your mouse over to the view controller (on the right) that we had on our storyboard originally. This will draw a line from the navigation controller all the way to the view controller
  7. Now release your mouse button at which point you will be presented with a dialog asking you what type of connection you want to create between the navigation and the view controller. Select the root View Controller item from the list by simply clicking on it.
  8. After this is done, the storyboard will show that your navigation controller is now connected to the original view controller.
  9. The most important step is to make our navigation controller the initial/root view controller. If we don't do this, the storyboard will use the view controller that we initially had as the initial view controller. Can you see that the view controller on the right side has a border around it. That indicates an initial view controller. To make our navigation the initial view controller, simply select the Navigation Controller under the Navigation Controller Scene panel in Interface Builder,  Now select the View menu in Xcode and choose View→Show Attributes Inspector. Once the attributes inspector is opened, under the View Controller category, check the Is Initial View Controller check box.
As you can see, now your navigation controller has a border around it. Now if you run your application, you will notice that the initial view controller has a navigation bar on top, indicating that this view controller now has a navigation controller. In the next recipes we will see how we can make use of the navigation controller to display new scenes on the screen.

We now have a navigation controller with a view controller inside it but our objective now is to trigger an action and then move from one view controller to another. Alright then; let's place a button on our view controller and push a view controller into the stack once the user presses the button.  Alright....
  1. Go back to your .storyboard file.
  2. In the Object Library, find the View Controller object and drag and drop it onto the storyboard, on the right side of our existing view controller.
  3. In Object Library, find the Button object and drag and drop it into the first view controller. Note that if you are zoomed out, Interface Builder will not allow you to drop a button onto a view controller. You need to double click on an empty space on your storyboard to zoom into it before Interface Builder allows you to drop UI components onto your view controllers.
  4. Now select the button,hold down the Control key on your key board and then hold down the left mouse button and on the button and drag all the way to the second view controller
  5. Now lift your fingers off the mouse button and the Control key on your keyboard. You will now be presented with a dialog . Simply click on the performSegueWithIdentifier:sender: item Now if you have a look at your storyboard, you will see that the first view controller is connected to the second view controller.
  6. Now if you run your app and tap on the button on the first view controller, you'll see that the second view controller will automatically get pushed onto the stack of view controllers. Once the second view controller is presented, you will see a back button on the navigation bar. If you press that button, you will be sent back to the first view controller.

Wednesday, 16 May 2012

Design Patterns and View Controllers

          Types of Design Patterns
    • Singleton
    • Delegation
    • Model View Controller       
           Singleton
           The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. 
           Ensure a class has only one instance, and provide a global point of access to it.
           Delegation
           A delegate is a type that references a method. Once a delegate is assigned a method,it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value.Delegates are declared using the keyword delegate.
    Note:Once instantiated, the delegate reference can be used directly as a method
           Model View Controller
           Model View Controller: In the Model-View-Controller (MVC) design pattern, a controller object provides the custom logic needed to bridge the application’s data to the views and other visual entities used to present that data to the use.  


      
  • View controller should encapsulate all of the behavior associated with managing the views in its view hierarchy.
  • Each view controller is responsible for managing a discrete part of your application’s user interface.
  • The view controller  acts  as the central coordinating agent for the view hierarchy, handling exchanges between its views and any relevant controller or data objects.
  • A view controller is a specific type of controller object that you use to present and manage a set of views.
    • View controller objects are descendants of the UI View Controller class, which is defined in the UIKit framework.
    • A view controllers provide a vital link between an application’s data and its visual view. 

      View Controller Class

    • View controller classes available in the UIKit framework along with some of the key classes used in conjunction with view controllers.
    • These classes are often used internally by view controller objects to implement special types of interface 

              Types of View Controller

            1. Custom View Controller
            2. Table View Controller
            3. Container View Controllers
                      i. Navigation Controller
                      ii.Tab Bar Controller
                      iii.Split View Controller
            4.Window based View Controller
           
          Custom View Controller
           Each custom view controller object you create is responsible for managing all      single view hierarchy.
           Table View Controller
           The UI Table View Controller  class is another  type of custom view controller designed specifically for managing  tabular  data.The class adds automatic support for many standard table-related behaviors such as selection management, row editing, table configuration, and others.
           Navigation Controller
           The navigation template provide a starting point for an application that uses a navigation controller .It provide a user interface configuration with navigation controller to display a list of item.Navigation controller’s primary job is to act as a manager of other view controllers.It also manages a few views. Specifically, it manages a navigation  bar that displays information about the user’s current location in the data hierarchy, a back button for navigating to previous screens, and any custom controls the current view controller  needs.The navigation controller also manages an optional toolbar, which can be used to display commands related to the current screen.
           Tab Bar Controller
           A tab bar controller is a container view controller that you use to divide your application into two or more distinct modes of operation  
           Split View Controller 
              Split template provide a starting point for an application that uses a split view controller.It provide user interface configuration with a split view controller and two view controller to manage a master detail style view.A split-view controller is a container  view controller that is typically used to implement master-detail interfaces Split-view controllers are supported on iPad only.
          Window based View Controller
           Window based view controller provide application delegate and window.

     

Getting Started iPhone Development



The iPhone changed everything.
The iPhone 4 “changed everything, again.” And now you’ve got the iPad to contend with, too. iOS devices are now capable word processors, e-readers, and video cameras. They are being used in business and medicine as enterprise devices, and the App Store is a platform for every developer to use, from one-man shows to big-name companies. Apple provides the software and we’ll help you with the knowledge—
let’s get started So, you want to build an iOS app...
Maybe you use an iPhone all the time and wish “it could do that.” Maybe you have an app you love that could be so much better. You might have a business that wants to leverage computing power that fits in your customers’ hands. Or perhaps you have an idea for an app that could start a business. There are a lot of motivations to want to code for iPhone and iPad, and lots of customers, too.
For iPhone development first you should be clear Programming Language like C,C++ ......and Object Oriented Programming language concepts or OOP(Object oriented Programming) pillars.
  1. Objects
  2. Class
  3. Inheritance
  4. Data Abstraction
  5. Data Encapsulation
  6. Polymorphism
  7. Dynamic Binding
  8. Message Passing
Note:Objective-C does not allow multiple inheritance. Therefore, every class is the direct descendant of, at most, one other class.

The root class of most Objective-C objects is the NSObject class. This class manages the runtime capabilities offered by iOS; as a result, any class that directly or indirectly inherits from NSObject will inherit these capabilities as well. As we will see later in this chapter, objects that inherit from NSObject can take advantage of Objective-C’s dis- tinctive memory management model.

Wednesday, 1 February 2012

SDK (software development kit)

The Software development Kit contains:
  • Xcode
  • Instrument
  • Dash Board
  • Simulator
  • Interface Builder

introduction to xcode

Xcode is the complete toolset for building Mac OS X and iOS applications — and with Xcode 4, the tools have been redesigned to be faster, easier to use, and more helpful than ever before. The Xcode IDE understands your project’s every detail, identifies mistakes in both syntax and logic, and will even fix your code for you. Quite simply, Xcode 4 will help you write better code.

Xcode 4 has a brand new user interface, built upon proven technologies that Apple itself uses to build Mac OS X and iOS, and that have produced over a quarter million Mac OS X and iOS apps.