Hi guys,
Sorry for the barrage of questions lately.
I have this code:
Its a test to try and figure out why [self locality] is being assigned nil on the "Outside" NSLog statement but being assigned a value on the "Inside" NSLog statement.
Here is my program output:
As you can see for some reason the "Outside" is executing before the "Inside" and it is preventing me from finishing my exercise.
I already looked at the documentation, but it doesn't seem to do anything. There is a property called "BOOL isGeocoding" but when I do not believe it does what I think it does because when I wrap it around the NSLog(@"Outside") line that line never executes, suggesting the geoencoder never finishes encoding its value.
Basically I am trying to make everything in the "reverseGeocodeLocation" block execute BEFORE the "NSLog(@"Outside") line and I am having trouble finding a way to do it. Any suggestions would be greatly appreciated.
Sorry for the barrage of questions lately.
I have this code:
Code:
-(id)initWithCoordinate:(CLLocationCoordinate2D)c title:(NSString *)t location:(CLLocation *)l
{
self = [super init];
if(self)
{
coordinate = c;
//Create date
NSString *date = [NSDateFormatter localizedStringFromDate: [NSDate date]
dateStyle:NSDateFormatterShortStyle
timeStyle:NSDateFormatterShortStyle];
//Create reverseGeocode
if(!geoCoder)
{
geoCoder = [[CLGeocoder alloc] init];
}
[geoCoder reverseGeocodeLocation:l
completionHandler:^(NSArray *placemarks, NSError *error) {
for(CLPlacemark *p in placemarks)
{
[self setLocality:[p locality]];
[B] NSLog(@"Inside: %@", [self locality]); //This executes second[/B]
[self setAdministrativeArea:[p administrativeArea]];
}
}];
[B] NSLog(@"Outside: %@", [self locality]); //This executes first!!![/B]
[self setTitle:t];
[self setSubtitle:date];
}
return self;
}
Its a test to try and figure out why [self locality] is being assigned nil on the "Outside" NSLog statement but being assigned a value on the "Inside" NSLog statement.
Here is my program output:
Code:
[B]2012-02-07 05:36:22.740 Whereami[2393:11603] Outside: (null)
2012-02-07 05:36:23.000 Whereami[2393:11603] Inside: San Francisco[/B]
As you can see for some reason the "Outside" is executing before the "Inside" and it is preventing me from finishing my exercise.
I already looked at the documentation, but it doesn't seem to do anything. There is a property called "BOOL isGeocoding" but when I do not believe it does what I think it does because when I wrap it around the NSLog(@"Outside") line that line never executes, suggesting the geoencoder never finishes encoding its value.
Basically I am trying to make everything in the "reverseGeocodeLocation" block execute BEFORE the "NSLog(@"Outside") line and I am having trouble finding a way to do it. Any suggestions would be greatly appreciated.
Last edited: