본문 바로가기

개발도구/iOS - 아이폰 개발

[아이폰] 클래스, 메소드 변수값 호출 전달

아래의 소스를 보시면 A CLASS에서 B CLASS을 접근하되 값을 넘겨주는것이다ㅏ.
넘겨줄 값의 형태와  받는 B CLASS의 포멧은 동일해야 하며
넘겨주는 방법은 B CLASS NAME:VALUE 이다

역시 B CLASS에 
-(void)B CLASS NAME:(포멧)VALUE 로 되어야 된다.

아래 소스 예제를 보면 이해하기에 편할듯 싶다

A===

  if(temp){

        [self addpush:temp];    

    }


B===

- (void)addpush:(NSString *)temp {

        NSLog(@"addpush_%@",temp);

[messages addObject:temp];

[tbl reloadData];

NSUInteger index = [messages count] - 1;

[tbl scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];

field.text = @"";

}