Skip to content

Instantly share code, notes, and snippets.

#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSLog(@"Programming is fun");
NSLog(@"Fun Fun");
}
return 0;
}
Type Constant Examples NSLog chars
char 'a','\n' %c
short int - %hi, %hx, %ho
unsigned short int - %hu, %hx, %ho
int 12, -97, oxFFE0, 0177 %i, %x, %o
unsigned int 12u, 100u, 0Xffu %u, %x, %o
unsigned long int 12UL, 100ul, 0xffeeUL %li, %lx, %lo
long long int 0xe5e5e5e5LL, 500ll %lli, %llx, %llo
unsigned long long int 12ull, oxffeeull %llu, %llx, %llo
float 12.34f, 3.1e-5f, 0x1.5p10, 0x1p-1 %f, %e, %g, %a
Method Quesstion or Action
-(BOOL) isKindofClass: class-object Is the object a member of class-object or a descendant?
-(BOOL) isMemberofClass: class-object Is the object a member of class-object?
-(BOOL) respondsToSelector: selector Can the object respond to the method specified by selector?
+(BOOL) instancesRespondToSelector: selector Can instances of the specified class respon to selector?
+(BOOL) isSubclassofClass: class-object Is the object of a subclass of the specified class?
-(id) performSelector: selector Apply the method specified by selector
-(id) performSlector: selector withObject: object Apply the method specified by selector passing the argument object
-(id) performSelector: selector w
@try{
//some codes
}
@catch (NSException *exception){
NSLog(@"Caught %@%@", exception.name, exception.reason);
}
initWithArray:
initWithArray:copyItems:
initWithContentsofFile:
initWithContentsofURL:
initWithObjects:
initWithObjects:count:
enum month { january = 1, february, march, april, may, june, july, august, september, october, november, december };
enum month thisMonth;
thisMonth = february;
#ifdef conditon
#define A B
#else
#define C D
#endif
#undef E
(struct date){ .month=7, .day=2, year=2011}
Creation and Initialization Initialization Instance Method Retrieval Instance Method
numberWithChar: initWithChar: charValue
numberWithUnignedChar: initWithUnsignedChar: unsignedCharValue
numberWithShort: initWithShort: shortValue
numberWithUnsignedShort: initWithUnsignedShort: unsignedShortVlaue
numberWithInteger: initWithInteger: integerValue
numberWithUnsignedInteger: initWithUnsignedInteger: unsignedIntegerValue
numberWithInt: initWithInt: intValue
numberWithUnsignedInt: initWithUnsignedInt: unsignedIntValue
numberWithLong: initWithLong: longValue
Method Description
+(id) stringWithContentsofFile:path encoding:enc error:err Creates a new string and sets it to the path contents
of a file specified by the path using character encoding env,
returning error in err if non-nil
+(id) stringWithContentsofURL:url encoding:enc error:err Creates a new string and sets it to the contents of url
using character encoding enc,
returning error in err if non-nil
+(id) string Creates a new empty string