objective-c 구문

2136 단어 objective-c
command line tool

@"there are %i in a year.", minutesInyear



- (int) myFunction (int x, int y) {}

void myFunction(void) {}

string

NSString *myString = @"hello";

NSDate *today = [NSDate date];



typedef int simonsInt;

simonsInt foo = 999;

typedef emun {window = 99} searPreference

#if DEBUG
....
#endif

NSString *msg = @"hello world";
*

NSLog(@"The value of message is %@", message);

[myObject someMethod];

result = [myObject someMethod]

[myobject someMethod:arg];

[myObject insertString: @"Hello" atIndex: 11];

[myObject someMethod: [anotherObject anotherMethod]]

+ - instance

if you own the object you must release it

if you don`t own the object you must not

alloc new copy retain release

NSDate *myDate = [NSDate new];

NSDate *myDate = [[NSDate alloc] init];

[myDate release];

[fred autorelease] , fred pool

[img]http://dl2.iteye.com/upload/attachment/0086/6439/0c20814b-c06f-31b5-92f0-2232184234c1.png[/img]
      autorelease:

create {
Employee *fred = [[Employee alloc] init];
[fred autorelease];
return fred;
}

@interface Employee : NSObject

@property NSString *name;

-(void) someMethod;

@end

@implementation Employee

@synthesize name, c;

-(void) someMethod{
NSLog();
}
@end

synthesize get set

#import "Employee.h"

-(int) addNumber:(int)a toNumber:(int)b;
toNumber 2nd part method name

@interface Player : NSObject
{
//instance variables
int score;
}
@end

NSArray *myarray = [NSArray arrayWithObjects:@"one", @"two", nil];

NSLog(@"the second element is : %@", [myarray objectAtIndex:1]);


좋은 웹페이지 즐겨찾기