태그 보관물: location

iOS 시뮬레이터에서 위치 이용

안드로이드 에뮬레이터는 말그대로 arm칩을 에뮬레이팅한 가상장치라 그지같은 속도로 욕을 많이 먹지만(잘 쓰지도 않음)
아이폰 시뮬레이터는 위치를 시뮬레이팅 해줄수가 없는 문제가 있다.
(update : Xcode 4.2의 시뮬레이터부터는 위치 시뮬레이팅을 지원한다)
이를 해결하기 위해서 시뮬레이터일 경우 코드상에서 특정 위치를 전송해주는 방법이다.

#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