라벨이 thread인 게시물 표시

This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. 오류 조치 방법

swift 3 에서 작성하는 도중에 이런 오류가 발생했다. This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread.  대충 내용은 백그라운드에서 메인 스레드를 접속해서 뭔가 안 맞는다는 이야기 같다.  검색 결과 디스패치를 구현할 때 백그라운드에서는 데이터 처리만 그리고 메인은 UI 처리만 하면 된다고 한다. DispatchQueue.global(qos: .background).async { // 오직 데이터 처리만 DispatchQueue.main.async { // 오직 UI } } 위와 같이 처리하니 오류가 안난다.

iOS6 에서 쓰레드(thread) 사용하는 법

간단하게 사용하는 방법으로 할 예정입니다. 라벨에 스레드로 10까지 더하는 걸 표시할 예정입니다. 먼저 라벨을 초기화 합니다. self.label.text = @"1"; 그 다음 스레드를 가동합니다. 타이머랑 비슷하네요. [ NSThread detachNewThreadSelector : @selector (threadtest) toTarget : self withObject : nil ]; 이제 스레드에서 호출한 threadtest 함수를 만들어야겠네요. -( void )threadtest {     @autoreleasepool {         // former code here         int i = [ self . label . text intValue ];         while (i <  10 ){             NSString *str_i = [ NSString stringWithFormat : @"%i" , i + 1 ];             [ self performSelectorOnMainThread : @selector (updateLabel:) withObject :str_i waitUntilDone : false ];             [ NSThread sleepForTimeInterval : 0.5f ];             i = [ self . labelCalendar . text intValue ];         }         [ NSThread exit ];     } } 보여주는 콘트롤은 별로로 빼야 한다고 해서 updateLabel로 뺐습니다. 이제 이 함수를 만들어 보겠습니다. -( void )updateLabel:( NSString *)text {     self . labelCalendar