Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 01-13-2011, 04:18 PM   #1 (permalink)
r@t
Registered Member
 
Join Date: Jan 2011
Posts: 21
r@t is on a distinguished road
Default Corrupted CLLocation coordinate NSString in a UIButton

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
r@t is offline   Reply With Quote
Reply

Bookmarks

Tags
cllocation, core location, latitude, longitude, uibutton

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 405
11 members and 394 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,924
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:25 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0