Core Location Services Problem

Discussion in 'Mac Programming' started by Blakeasd, Apr 21, 2011.

  1. macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    Hello,
    I am just trying out Core Location for fun and I am having some problems.
    I am trying to get the latitude of where I am but it is not working. There is no error, the problem is that my latitude displays as 0. Here is my code:
    Code:
    
    -(void)awakeFromNib{
        
        NSString *lattitude = [[NSString alloc]initWithFormat:@"%g",location.coordinate.latitude];
        [locationField setStringValue:lattitude];
                               
       
    
    }
    
    In my header file the only property I have set is the location property. I set the property like this:
    Code:
    
    @property(readonly NS_NONATOMIC_IOSONLY)CLLocation *location;
    
    
    Does anyone know why my latitude shows as 0? I am sure it is something simple I forgot.
    Thanks
     
  2. macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    Possibly because location is nil. Sending a message to nil results in 0. Where do you create a CLLocation and set your location property?
     
  3. thread starter macrumors 6502a

    Joined:
    Dec 29, 2009

Share This Page