Hi
I am having a problem with a "latLong" NSString that when read from inside a UIButton method it either crashes with EXC_BAD_ACCESS or occasionally reads off reams of CL code.
I have the following method in the tVC successfully generating realtime location data...
tableViewController.m
Code:
- (void)locationUpdate:(CLLocation *)location {
int degrees = location.coordinate.latitude;
double decimal = fabs(location.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d degs,%d mins,%1.2f secs", degrees, minutes, seconds];
degrees = location.coordinate.longitude;
decimal = fabs(location.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d degs,%d mins,%1.2f secs", degrees, minutes, seconds];
NSString *tempLatLong = [[NSString alloc]init];
self.latLong = tempLatLong;
[tempLatLong release];
latLong = [NSStringWithFormat:@"L/L:%@%@",lat,longt];
NSLog(@"%@",latLong); // All looks good in debugger
}
and i would like to pass this "latLong" NSString to the button method shown below to provide a record of the location of the device when the button is tapped.
same tableViewController.m
Code:
- (void)statusButtonTapped:(id)sender event:(id)event{
//establish indexpath
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
NSLog(@"%@",latLong); // at this point it shows as reams of CL code in the debugger or crashes
NSMutableArray *arrayGeoTag = [NSMutableArray arrayWithArray:geoTag];
[arrayGeoTag replaceObjectAtIndex:indexPath.row withObject:latLong];
NSArray *tempGeoTag = [[NSArray alloc]init];
self.geoTag = tempGeoTag;
[tempGeoTag release],tempGeoTag = nil;
self.geoTag = arrayGeoTag;
NSLog(@"%@",geoTag);
}
Any help to solve this issue would be greatly appreciated