2011-10-03 60 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。 –