Sunday, 9 December 2012

structure in objective C

A C structure is a compound data type: it combines multiple data types into a single type, which can be passed around as a single entity and can be accessed by those names through the compound entity, using dot-notation. The iOS API has many commonly used structs.
For example,  CGPoint is defined as follows:
struct CGPoint
{
     CGFloat x;
    CGFloat y;
};
 typedef struct CGPoint CGPoint;

So we can write:
    CGPoint myPoint;
    myPoint.x = 4.3;
    myPoint.y = 7.1;

Another iOS struct,
CGSize:
struct CGSize
{
    CGFloat width;
    CGFloat height;
};
 typedef struct CGSize CGSize;

Put a CGPoint and a CGSize together and you’ve got a CGRect:
struct CGRect
{
    CGPoint origin;
    CGSize size;
};
typedef struct CGRect CGRect;

Friday, 7 December 2012

Format String Tokens in objective c

Format String Tokens
There are several methods in Cocoa, such as NSLog and [NSString stringWithFormat], that can use format strings with a list of arguments. These format strings can contain all of the normal printf-style tokens, as well as a Cocoa-specific token for objects.
%@    Print as an object
%d or %i signed decimal
%o    unsigned octal
%s    string
%u   unsigned decimal
%x   unsigned hexadecimal

For other information open a Terminal window and enter "man printf" at the prompt.

Objective-C-Defined Types

Hello,

Here is defined types that are use in iOs development commonly. If any important type is left then please write it in comment i'll add it in detail so its useful to other,

id             An object reference (a pointer to its data structure)
Class       A selector ( a compiler - assigned code that identifies a method name )
IMP         A pointer to a method implementation that returns an id
BOOL
nil            A null object pointer , (id)0
Nil           A null class pointer, (class)0