블로그/아이폰/iOS
[ios 비동기 처리 방법] 시간이 오래 걸리는 작업 처리법
EntusApps
2014. 8. 29. 16:22
시간이 오래 걸리는 작업 처리시 UI부분이 멈추는데, 아래 코드처럼 비동기로 처리하면 메인 UI는 할일하고 저기 들어있는 시간이 오래 걸리는 작업은 글로벌큐에서 비동기로 처리됨.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//시간이 오래 걸리는 작업 코드!
});
메인큐에서 처리하고 싶으면
dispatch_async(dispatch_get_main_queue(), ^{
//메인 큐에서 실행할 코드!
});