Chap 4 location managers error at build


#1

After following the directions up to page 83 I get more errors than i can put on here. I am using ios sdk 4.3 with xcode 4.0.2 please help someone!!
I am getting lots of linker errors!

[code]- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

locationManager = [[CLLocationManager alloc] init];

[locationManager setDistanceFilter:kCLDistanceFilterNone];

[locationManager setDelegate:self];

[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

//Tell our manager to start looking for its location immediately
[locationManager startUpdatingLocation];

[self.window makeKeyAndVisible];
return YES;

}

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%@", newLocation);
}

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@“Could not find location: %@”, error);
}
[/code]


#2

Is the current version of Xcode the problem?? I hope someone here can help me with my problem.


#3

Can you provide a few of the errors you’re getting? Learning to read the console and/or debugger can be cryptic at first, but it certainly helps!


#4

Have you added the CoreLocation framework to the target?

Have you imported <CoreLocation/CoreLocation.h> at the top of WhereamiAppDelegate.h?

Have you declared CLLocationManager *locationManager in WhereamiAppDelegate.h?


#5

i get a ‘server did not accept client registration 68’ error in my log. XCode version 4.1 Mac OSX Lion. It hasn’t requested that i give it access to get a gps location or anything. Since, in the book, you mention using the simulator as an option I don’t see how it could be a problem. I get a warning for [locationManager selfDelegate:self] - [quote]warning: class ‘WhereamiAppDelegate’ does not implement the ‘CLLocationManagerDelegate’ protocol
[/quote]

any help Joe? thanks…


#6

the error that i mention above was fixed by the hack that you gave us in another thread. Now that I have to add the protocols in the header file i get the following error/warning.

[quote]#import “WhereamiAppDelegate.h”

@implementation CLLocationManager (TemporaryHack)

  • (void)hackLocationFix
    {
    CLLocation *location = [[CLLocation alloc] initWithLatitude:42 longitude:-50];
    [[self delegate] locationManager:self didUpdateToLocation:location fromLocation:nil];
    }

  • (void)startUpdatingLocation
    {
    [self performSelector:@selector(hackLocationFix) withObject:nil afterDelay:0.1];
    }

@end

@implementation WhereamiAppDelegate : NSObject
<UIApplicationDelegate, CLLocationManagerDelegate> //warning/error: Parse Issue: Protocol qualifiers without ‘id’ is archaic

@synthesize window = _window; //ERROR - Parse Issue: Prefix attribute must be followed by an interface or protocol

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    locationManager = [[CLLocationManager alloc] init];

    //set delegate
    [locationManager setDelegate:self]; //warning: class ‘WhereamiAppDelegate’ does not implement the ‘CLLocationManagerDelegate’ protocol

    //filter
    [locationManager setDistanceFilter:kCLDistanceFilterNone];

    //accuracy
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

    [locationManager startUpdatingLocation];

    // Override point for customization after application launch.
    [self.window makeKeyAndVisible];
    return YES;
    }[/quote]


#7

Ah, you have added the <UIApplicationDelegate, CLLocationManagerDelegate> to the @implementation WhereamiAppDelegate. These should be on the @interface WhereamiAppDelegate, in the .h file.

@interface WhereamiAppDelegate <UIApplicationDelegate, CLLocationManagerDelegate>