Expanding the Homwpwner with a CLLocation


#1

I have rewritten the Homepwner app to a flowerCollectorApp.

I want the app to record a CLLocation together with the date when a new Item is registered, and have added a CLLocation*myLocation to the instancevariables of BNRItem.
I have managed to make the BNRItem find a location when a new item is added, but I can’t figure how to set the BNRItem.myLocation to register the findings of locationManager.
Anyone out there feeling giving a newbe some hints? It will be very appriciated.

BNRItem.h
@property (nonatomic, retain,strong) CLLocation *myLocation;
@property (nonatomic, retain, strong)CLLocationManager *locationManager;

[code]BNRItem.m

  • (id)initWithItemName:(NSString *)name
    valueInDollars:(int)value
    serialNumber:(NSString *)sNumber
    {
    // Call the superclass’s designated initializer
    self = [super init];

    // Did the superclass’s designated initializer succeed?
    if(self) {
    // Give the instance variables initial values
    [self setItemName:name];
    [self setSerialNumber:sNumber];
    [self setValueInDollars:value];
    dateCreated = [[NSDate alloc] init];

      locationManager = [[CLLocationManager alloc] init];
      [locationManager setDelegate:self];
      locationManager.desiredAccuracy = kCLLocationAccuracyBest;
      locationManager.distanceFilter = 50.0f;
      [locationManager startUpdatingLocation];
      myLoction= [[CLLocation alloc] init];[/b]
    

    } //somehow set myLocation = newLocation :-S

    // Return the address of the newly initialized object
    return self;
    }

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

}

  • (void) locationManager: (CLLocationManager *) manager
    didFailWithError: (NSError *) error
    {
    NSLog(@“Error obtaining location %@”,error);

}[/code]