views:

23

answers:

1

I have a Delegate class that handles responses from CLLocationManager and prints them via printf(). Is there some type of busy loop I can put in main() so that the program stays open and keeps CLLocationManager connected to Delegate happily processing events?

#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;
}
+1  A: 

This is what NSRunLoop is for, and CLLocationManager is explicitly documented as requiring one (search for “run loop” on that page), so that's what you need to do: Run the run loop.

Peter Hosey