2011-10-03 59 views
1

我在Lion上使用XCode 4.1。在iOS模擬器中運行Core Location代碼時出現以下錯誤:核心位置不能在iOS模擬器中工作

Starting Location Updates 
server did not accept client registration 68 

不知道如何解決?

地點代碼:

// 
// LocationGetter.m 
// CoreLocationExample 
// 
// Created by Matt on 7/9/09. 
// Copyright 2009 iCodeBlog. All rights reserved. 
// 

#import "LocationGetter.h" 
#import <CoreLocation/CoreLocation.h> 

@implementation LocationGetter 

@synthesize locationManager, delegate; 

BOOL didUpdate = NO; 

- (void)startUpdates 
{ 
    NSLog(@"Starting Location Updates"); 

    if (locationManager == nil) 
     locationManager = [[CLLocationManager alloc] init]; 

    locationManager.delegate = self; 

    // You have some options here, though higher accuracy takes longer to resolve. 
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer; 
    [locationManager startUpdatingLocation];  
} 

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
{ 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your location could not be determined." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    [alert show]; 
    [alert release];  
} 

// Delegate method from the CLLocationManagerDelegate protocol. 
- (void)locationManager:(CLLocationManager *)manage didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
    if (didUpdate) 
     return; 

    didUpdate = YES; 

    // Disable future updates to save power. 
    [locationManager stopUpdatingLocation]; 

    // let our delegate know we're done 
    [delegate newPhysicalLocation:newLocation]; 
} 

- (void)dealloc 
{ 
    [locationManager release]; 

    [super dealloc]; 
} 

@end 
+0

發佈您的位置代碼。 – WrightsCS

回答

0

您可能正在使用的4.3模擬器是不是跟這個Xcode的支持獅子。

+0

如何使用其他模擬器?我以爲4.3是最新的生產版本? –

+0

你可以使用5.0模擬器。 – TommyG

+0

如何使用hte 5.0模擬器? –

1

位置服務僅適用於iOS 5模擬器。您應該能夠更改模擬器或Xcode中的設備。您可以將模擬器內的位置更改爲自定義位置或Apple內置的其中一個位置。

*注:Xcode的4.3和iOS 5模擬器只爲今天提供給付費開發商(2011/10/5)

+0

我是一名付費開發者,除了在我的新機器上,我從App Store安裝了XCode。我應該如何繼續?我應該擦掉它,只使用developer.xcode.com中的XCode? –

+0

如果您想使用位置服務,則必須從開發者門戶網站獲取該版本。只是沒有其他辦法。 Lion的更新應該在幾個星期內發佈,所以你可以隨時等待,但是如果你現在需要測試,你需要Apple的最新GM(Gold Master)版Xcode。 –