레이블이 Objective-C인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Objective-C인 게시물을 표시합니다. 모든 게시물 표시

2010년 8월 7일 토요일

Objective-C Outlet

objective-c 에서는 다른 객체를 참조 하는 변수를 outlet 이라고 부른다. 
outlet 은 GUI 구성을 하는 Interface Builder 에서 변수로 다른 객체를 연결 할때 사용함. 

IBOutlet UIView *view2;


위와 같은 형태로 주로 사용되는데 
IBOutlet 에서 IB는 Interface Builder의 줄인말인듯. 

참조를 하기 위해서는 아래와 같이 선언하고 .m 에서 접근 하면 된다. 

@property (nonatomic, retain) IBOutlet UIView *view2;

2010년 6월 27일 일요일

Protocols - Objective-C

Protocol : 메소드 선언의 집합

java의 interface라는 개념이 Protocol을 도입한 개념임. 

서로 다른 객체가 같은 메소드의 집합을 가지는 경우, 상속 관계는 아님. 

프로토콜은 메소드의 명칭들을 정해 놓으면 그 프로토콜을 따를 때 메소드의 명칭들이 같아지므로 사용성이 좋아지는 것을 목적으로 한다. 



2010년 3월 11일 목요일

서버에서 다운 받기 - Objective-c

erica 예제 c3-06-Synchronous Downloads


NSURL *url = [NSURL URLWithString: [urlArray objectAtIndex:[which intValue]]];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSURLResponse *response;
NSError *error;

NSData* result = [NSURLConnection sendSynchronousRequest:
theRequest
theRequest returningResponse:&response error:&error];



덤으로 무비 플레이어

- (void) startPlayback : (id) sender
{
MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:self.savePath]];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie play];
}