Really confused with Whereami App error


I’m brand new to programming, brand new to Objective C, brand new to Coco and Brand new to iPhone Programming.
I’m working through the iPhone Programming: The Big Nerd Ranch Guide and Programming in Objective-C 2.0 that was recommended in the intro to iPhone Programing.

I’ve tried this every which way but i just don’t understand were I am getting this error from.

In WhereamiAppDelegate.m

// WhereamiAppDelegate.m
// Whereami
// Created by Roland Willwerth on 4/22/11.
// Copyright MyCompanyName 2011. All rights reserved.

#import “WhereamiAppDelegate.h”
#import “MapPoint.h”

@implementation WhereamiAppDelegate

  • (BOOL) application:(UIApplication *)application
    didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
    //Creat location manager object -
    locationManager = [[CLLocationManager alloc] init];

    //Make this instacne of WheramiAppDelegate the delegate
    //it will send its messages to our WhereamiAppDelegate
    [locationManager setDelegate:self];

    //We want all results from the location manager
    [locationManager setDistanceFilter:kCLDistanceFilterNone];

    //And we want it to be accurate as possible
    //regardless of how much time/power it takes
    [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

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

    // [locationManager startUpdatingLocation];
    [mapView setShowsUserLocation:YES];
    [window makeKeyAndVisible];

    return YES;

  • (BOOL) textFieldShouldReturn:(UITextField *)tf
    [self findLocation];
    [tf resignFirstResponder];
    return YES;

@synthesize window;

  • (void)dealloc
    [locationManager setDelegate:nil];
    [super dealloc];

  • (void) locationManager: (CLLocationManager *)manager
    didUpdateToLocation: (CLLocation *)newLocation
    fromLocation: (CLLocation *)oldLocation
    NSLog(@"%@", newLocation);
    // How many second ago was this new location created?
    NSTimeInterval t = [[newLocation timestamp] timeIntervalSinceNow];
    // CLLocationManagers will return the last found location of the
    // device first, you don’t want that data in this case.
    // If this location was made more than 3 minutes ago, ignore it.
    if (t < -180) {
    // This cached data, you don’t want it, keep looking
    MapPoint *mp = [[MapPoint alloc]
    initWithCoordinate: [newLocation coordinate]
    title: [locationTitleField text]];
    [mapView addAnnotation:mp];
    [mp release];

    [self foundLocation];

  • (void) locationManager: (CLLocationManager *)manager
    didFailWithError: (NSError *)error
    NSLog(@“Could not find location: %@”, error);

  • (void) mapView: (MKMapView *)mv didAddAnnotaationViews : (NSArray *)views
    MKAnnotationView *annotationView = [views objectAtIndex:0];
    id mp = [annotationView annotation];
    MKCoordinateRegion region =
    MKCoordinateRegionMakeWithDistance([mp coordinate], 250, 250);
    [mv setRegion:region animated:YES];

  • (void) findLocation
    [locationManager startUpdatingLocation];
    [activityIndicator startAnimating];
    [locationTitleField setHidden:YES];

  • (void) foundLocation
    [locationTitleField setText:@""];
    [activityIndicator stopAnimating];
    [locationTitleField setHidden:NO];
    [locationManager stopUpdatingLocation];


under - (void) locationManager: (CLLocationManager *)manager didFailWithError: (NSError *)error { NSLog(@"Could not find location: %@", error); } I’m getting a:
error:wrong type argument to unary minus
error: expected ‘:’ before ‘:’ token

and under@end
I get:
error: expected declaration or statement at end of input
error; expected declaration or statement at end of input
warning: "@end’ missing implimentation of class WhereamiAppDelegate
warning; method definition for ‘-foundLocation’ not found
warning; method definition for ‘-findLocation’ not found

I seriously feel lost. I have no idea what i’m doing wrong here.



Looks like you have the curly brace round the wrong way

if (t < -180) {
// This cached data, you don’t want it, keep looking
{ <---------- should be }




Your right. Thanks so much. Im so embarrassed.