일부 위치 데이터가 포함 된 클래스 인스턴스를 만드는 응용 프로그램이 있습니다.appDelegate에서 CLLocation 속성을 요청할 때 응용 프로그램이 충돌합니다.
앱 대리인에서 위치 서비스를 설정하고 위치 데이터를 가져 오기 시작합니다.
다른 클래스의 CLLocation 인스턴스에 연결할 수 있도록 최신 위치를 속성으로 선언합니다.
내 캡처 클래스는 init 메서드가 호출 될 때 호출 할 때 CLLocation을 가져옵니다.
//Designated initialiser
-(id) initWithVideoPath:(NSString *) vPath
userNotes:(NSString *) uNotes
retentionState:(NSString *) rState
{
//Call the super classes designated initializer
[super init];
//Get a pointer to the application delegate so we can access the location props
Rolling_VideoAppDelegate *appDelegate = (Rolling_VideoAppDelegate*)[UIApplication sharedApplication].delegate;
//If superclass failed to init
if (!self)
return nil;
//Give the variables some initial values
[self setVideoPath:vPath];
[self setUserNotes:uNotes];
[self setRetentionState:rState];
dateCreated = [[NSDate alloc] init];
mp = [[MapPoint alloc]initWithCoordinate:[[appDelegate latestLocation]coordinate]];//get the location from the coords from appDelegate
return self;
[dateCreated release];
}
그러나 mapPoint init을 호출하면 앱이 다운됩니다. 문제는 제대로 CLLocation 정보를 얻지 못한다는 것입니다.
아무도 도와 줄 수 있습니까? 사전에
감사합니다,
리치
LocationManager를 처음 시작할 때'latestLocation' ivar이 초기화되지 않았다고 생각합니다. '-application : didFinishLaunchingWithOptions :'메소드에서 다음과 같이 초기화하십시오 :'latestLocation = [[CLLocation alloc] initWithLatitude : 0.0f longitude : 0.0f];'. 제대로 출시하는 것을 잊지 마십시오. –