Saturday, 24 November 2012

Classes

In Objective-C, you define objects by defining their class. The class definition is a prototype for a kind of object; it declares the instance variables that become part of every member of the class, and it defines a set of methods that all objects in the class can use. All instances of a class have access to the same set of methods, and they all have a set of instance variables cut from the same mold. Each object gets its own instance variables, but the methods are shared.

Class Names in Source Code

In source code, class names can be used in only two very different contexts. These contexts reflect the dual role of a class as a data type and as an object:
1. The class name can be used as a type name for a kind of object. For example:

Rectangle *anObject;
anObject = [[Rectangle alloc] init];

2. In any other context, you must ask the class object to reveal its id (by sending it a class message). The example below passes the Rectangle class as an argument in an isKindOf: message.

if ([anObject isKindOf:[Rectangle class]])

Tuesday, 13 November 2012

Messages


To get an object to do something, you send it a message telling it to apply a method. In Objective-C, message expressionsare enclosed in square brackets:
    [receiver message]
The receiver is an object, and the message tells it what to do. In source code, the message is simply the name of a method and any arguments that are passed to it. When a message is sent, the run-time system selects the appropriate method from the receiver's repertoire and invokes it.
For example, this message tells the myRect object to perform its display method, which causes the rectangle to display itself:
    [myRect display];

ID


In Objective-C, objects are identified by a distinct data type, id. This type is defined as a pointer to an object--in reality, a pointer to the object's data (its instance variables). Like a C function or an array, an object is identified by its address. All objects, regardless of their instance variables or methods, are of type id.
id ObjectName;
The keyword nil is defined as a null object, an id with a value of 0. idnil, and the other basic types of Objective-C are defined in the header file objc.h, which is located in the objc subdirectory of  NextDeveloper/Headers.

Monday, 12 November 2012

I am developer I have no life....


Sunday, 11 November 2012

The Receiver's Instance Variables

A method has automatic access to the receiving object's instance variables. You don't need to pass them to the method as arguments. Every method assumes the receiver and its instance variables, without having to declare them as arguments. A method has automatic access only to the receiver's instance variables. If it requires information about a variable stored in another object, it must send a message to the object asking it to reveal the contents of the variable.

Objects

In Objective-C, these operations are known as the object's methods; the data they affect are its instance variables. In essence, an object bundles a data structure (instance variables) and a group of procedures (methods) into a self-contained programming unit. For example, if you are writing a drawing program that allows a user to create images composed of lines, circles, rectangles, text, bit-mapped images, and so forth, you might create classes for many of the basic shapes that a user will be able to manipulate. A Rectangle object, for instance, might have instance variables that identify the position of the rectangle within the drawing along with its width and its height. Other instance variables could define the rectangle's color, whether or not it is to be filled, and a line pattern that should be used to display the rectangle. A Rectangle would have methods to set the rectangle's position, size, color, fill status, and line pattern, along with a method that causes the rectangle to display itself. Moreover, an object sees only the methods that were designed for it; it can't mistakenly perform methods intended for other types of objects.

Saturday, 3 November 2012

Objective-C Language


Objective-C syntax is a superset of standard C syntax, and its compiler works for both C and Objective-C source code. The compiler recognizes Objective-C source files by a ".m'' extension, just as it recognizes files containing only standard C syntax by a ".c'' extension. The Objective-C language is fully compatible with ANSI standard C. Objective-C can also be used as an extension to C++. At first glance, this may seem superfluous since C++ is itself an object-oriented extension of C. But C++ was designed primarily as "a better C,'' and not necessarily as a full-featured object-oriented language. It lacks some of the possibilities for object-oriented design that dynamic typing and dynamic binding bring to Objective-C. At the same time, it has useful language features not found in Objective-C. When you use the two languages in combination, you can assign appropriate roles to the features found in each and take advantage of what's best in both.

What is Delegation??

Many of the UIKit classes in iOS SDK use the Delegation design pattern. Delegation means that you designate one object to act on behalf of another object. A common example of this is the table view in UIKit. A table view will require an object to act as a delegate to do things like return the number of rows in a section, return a table cell and so on.

Delegation is a nice way to handle this situation. What I do is have the parent table view controller act as a delegate for the child editing view. When a user is done writing a note the editing view controller will send a message back to the parent table view controller. This gives me a chance to update the UI with the new note information.


You are going to need to do these things to use Delegation:

Define a protocol for ChildEditor.
Add a delegate property to ChildEditor that requires the protocol from step 1.
Add a NSIndexPath property to ChildEditor to remember what table view cell the string is displayed in.
When ChildEditor updates a string it must send a message to the delegate property from step 2
ParentTable must adopt the protocol from the step 1.
ParentTable must implement the delegate method that corresponds to the message that will be sent when ChildEditor updates a string (this is when the UI is updated).
Before a new ChildEditor is pushed onto the navigation controller set the delegate property to the ParentTable (you can use the self keyword here).
Before a new ChildEditor is pushed onto the navigation controller set the indexPath property to the property that you get in the didSelectRowAtIndexPath method.

Xcode

Xcode is an Integrated Development Environment (IDE) containing a suite of software development tools developed by Apple for developing software for OS X and iOS. First released in 2003, the latest stable release is version 4.5.1 and is available via the Mac App Store free of charge for Mac OS X Lion and OS X Mountain Lion users. Registered developers can download preview releases and previous versions of the suite through the Apple Developer website. 

About Me

Hello everyone, This is Akii, from India. I am iOS developer.

 
© Copyright 2035 iOS Developer
Theme by Yusuf Fikri