Objective C method with parameters
I needed to create a new method with 2 argument. I also need to call this method.
Easier said then done. Rather than try to add to the already volumnious documentation out there regarding objective c method name and parameters, here is what i did:
My declaration. It's a method called "updateLatLong" that has 2 arguments (a longitude and latitude)
-(void)updateLatLong:(NSString *)latitude longitude:(NSString *)longitude;
Here's how I called it (a little verbose since I had to convert doubles to Strings)
NSMutableString *mylat = [[[NSMutableString alloc] init] autorelease];
[mylat appendFormat: @"", fabs(newLocation.coordinate.latitude)];
NSMutableString *mylong = [[[NSMutableString alloc] init] autorelease];
[mylong appendFormat: @"", fabs(newLocation.coordinate.latitude)];
[self.delegate updateLatLong:mylat longitude:mylong];
Notice how the first agrument (latitude) is passed by not named. Crazy!

Comments
Post new comment