views:

34

answers:

2

i fill a string with coordinates , thats working fine. but how can i delete the content of this string.

PS: i use this string in a web services. the web services takes the string and convert it in the typ double.

if i make lat = nil; it dosent work.

here the code:

double degreesLat = newLocation.coordinate.latitude;
lat = [NSString stringWithFormat:@"%1.4f",degreesLat];
A: 
lat = @""; 

will work if you just want to set the string to be blank.

Jesse Naugher
thank for the fast reply. i tried but i doesnt work. i will try something in the webservice.
A: 

NSString is immutable; you can't change the contents of the NSString pointed to by lat in your example code. You can change the NSString instance that lat points to though. For example, you could do:

lat = @""; // sets lat to an empty string

If you want lat to be a string that allows you to change its value, you can use NSMutableString.

GregInYEG
but no i get the warning "incompatible Objective-C types assigning 'struct NSString', expected 'struct NSMutableString'. the code in the.h file NSMutableString *lat; @property (nonatomic, retain) NSMutableString *lat; and in the .m file double degreesLat = newLocation.coordinate.latitude; lat = [NSMutableString stringWithFormat:@"%1.4f",degreesLat];
i get it, like this it work. lat=[[NSMutableString alloc] initWithString:@""];