Bronze Challenge


#1

I had posted this in the IPhone development forum by mistake. Below is my answer for the Bronze challenge. I added the variable thinking there may be times that you do not want to hard code the distanceFilter.

WhereamiViewController.h

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

//add to proclaim that that the WhereamiViewController conforms to teh CLLocationManagerDelegate protocol.
@interface WhereamiViewController : UIViewController

{
CLLocationManager *locationManager;
}
[color=#FF4000]@property int refreshDistance;[/color]

@end

Procedure from WhereamiViewController.m

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {

//Set the refreshDistance for the distanceFilter.
[color=#FF4000] [self setRefreshDistance:50];[/color]

//Create location manager object
locationManager = [[CLLocationManager alloc]init];

//Set the locationManager Deligate
[locationManager setDelegate:self];

//Set the location manager to as accurate as possible --may consume more time / power
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];

[color=#FF0040] [locationManager setDistanceFilter:refreshDistance];[/color]

//Start looking for location
[locationManager startUpdatingLocation];
}
return self;
}


#2

Some code looks a bit redundant or maybe I don’t get something.
My code is just
[locationManager setDistanceFilter: 50];


#3

Since the exercise stated 50m, I just took the same approach and implemented:

[locationManager setDistanceFilter:50]