CLLocationManager의 응답을 처리하고 printf()를 통해 출력하는 Delegate 클래스가 있습니다. main()에 넣을 수있는 busy loop가 있나요? 그래서 프로그램이 열린 상태로 유지되고 CLLocationManager가 이벤트를 행복하게 처리하는 Delegate에 연결되도록 유지합니까?CLI 코코아 애플리케이션에서 어떻게 이벤트 루프를 구현합니까?
#import <Foundation/Foundation.h>
#import "Delegate.h"
#import <CoreLocation/CoreLocation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Delegate *del = [Delegate alloc];
CLLocationManager *locationManager;
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = del;
[locationManager startUpdatingLocation];
// Something goes here
[pool drain];
return 0;
}
'CLLocationManager'가 다른 스레드에서 멋진 프로그램을 실행하면 프로그램을 유지하기 위해 뭔가가 필요합니다. NSApplicationMain (argc, argv) 또는'dispatch_main()'('')를 사용하십시오. 'dispatch_main'은 절대로 돌아 오지 않을 것이기 때문에'풀 드레인 (pool drain) '이 호출 될 가능성은 없습니다. –
zneak
NSRunLoop을 사용하여 상처를 입음 * runLoop = [NSRunLoop currentRunLoop]; [runLoop run]; –