Computer/iOS

performSelectorOnMainThread implicit conversion of 'int' to 'id' is disallowed with arc

알찬돌삐 2014. 12. 17. 10:44

시간이 소요되거나 http 통신이 이루어질 경우 메인스레드가 해당 작업을 하는중이어서 앱이 먹통이 됩니다.

이에 쓰레드(NSThread)로 처리를 해야 하는데,

쓰레드에서 메인쓰레드를 호출하려고 하니 에러가 납니다.


- (void) indicator:(BOOL) chk {

    if (chk == TRUE) [ActivityIndicatorView startAnimating];

    else [ActivityIndicatorView stopAnimating];

}


- (void) subThread {

[self performSelectorOnMainThread:@selector(indicator:) withObject:[NSNumber numberWithBool:TRUE] waitUntilDone:YES];

}


이렇게 적용하였는데, 아래와 같은 에러가 나는 것이다.

performSelectorOnMainThread implicit conversion of 'int' to 'id' is disallowed with arc

열심히 구글링한 결과 (사실 조금만 했음)..

코드를 아래처럼 바꾸라고 하였다.

시킨대로 했더니 성공.


- (void) indicator:(NSNumber *) chk {

    BOOL value = [chk boolValue];

    if (value == TRUE) [ActivityIndicatorView startAnimating];

    else [ActivityIndicatorView stopAnimating];

}

- (void) subThread {

[self performSelectorOnMainThread:@selector(indicator:) withObject:[NSNumber numberWithBool:TRUE] waitUntilDone:YES];

}


'Computer > iOS' 카테고리의 다른 글

UITableViewCell 재사용...  (0) 2014.12.23