开发者

Core Location not working in iOS Simulator in Lion

开发者 https://www.devze.com 2023-04-10 03:01 出处:网络
I am using XCode 4.1 on Lion. I am getting the following error when running Core Location code in the iOS Simulator:

I am using XCode 4.1 on Lion. I am getting the following error when running Core Location code in the iOS Simulator:

Starting Location Updates
server did not accept client registration 68

Not sure how to resolve?

Location Code:

//
//  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;

    // D开发者_JAVA技巧isable future updates to save power.
    [locationManager stopUpdatingLocation];

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

- (void)dealloc
{
    [locationManager release];

    [super dealloc];
}

@end


The location services only work in the iOS 5 simulator. You should be able to change devices in the simulator or from Xcode. You can change your location from inside the simulator to a custom location or to one of the locations Apple has built-in.

*NOTE: Xcode 4.3 and iOS 5 Simulator are only available to paid developers as of today (10/5/2011)


You should take a look at: How to find your current location with CoreLocation.

Aslo, you have the option to choose location when your using the iOS Simulator under Debug.

Core Location not working in iOS Simulator in Lion


You are probably using the 4.3 simulator which is not supported on Lion with this xcode.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号