본문 바로가기
개발/Object C

Xcode 3.2.6의 iOS 시뮬레이터에서 위치 이용

by belitino 2012. 4. 15.

출처: http://milkdrops.net/index.php/archives/684

Xcode 3.2.6에 포함된 iOS 시뮬레이터에서는 위치를 지정해줄 수 없는데, 이를 코드상에서 해결해주는 방법이 있다.

#if TARGET_IPHONE_SIMULATOR

@interface CLLocationManager (Simulator)
@end

@implementation CLLocationManager (Simulator)

-(void)startUpdatingLocation {
    CLLocation *simulLoc = [[[CLLocation alloc] initWithLatitude:37.381 longitude:127.134] autorelease]; // 경도, 위도를 넣어주면 됨
    [self.delegate locationManager:self
               didUpdateToLocation:simulLoc
                      fromLocation:simulLoc];
}

@end

#endif // TARGET_IPHONE_SIMULATOR