Heads up, I'm an absolute newb when it comes to OBJ-C!
I'm currently putting together and IOS app and utilising pre-loaded data listings/locations from my client. The coordinates to each listing/location has are in DMS, eg
S:35 00.065
E:148 06.660
There are thousands of listings and I can't go and change this over for each one. I'm currently importing that data via a WordPress JSON API (WP REST API Plugin). The app I'm making pulls that JSON data in and populates accordingly.
The format is simply 'east' and south' from the JSON URL.
http://example.com/api/get_recent_posts/?custom_fields=name,east,south,image,address,type,Postend&page=%ld
I have no idea how to convert the east and south into lat and long for the code. Everything is ready to go except this predicament!
Everything I find on here leads to expired or dead links for their respective tutorials, in Javascript, PHP, or is reversing LAT LONG to DMS. :(
Thanks in advance!
--- EDIT WITH POSSIBLE ANSWER ---
Thanks to #ronak-chaniyara for the answer. Just having troubles implementing into current code. Existing code from template below:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *decodedText1 = [_restaurant.name stringByReplacingOccurrencesOfString:#"’" withString:#"'"];
NSString *decodedText = [decodedText1
stringByReplacingOccurrencesOfString:#"&" withString:#"&"];
self.title = _restaurant.type;
self.barname.text = decodedText;
self.address.text = _restaurant.location;
[[self navigationController] setNavigationBarHidden:NO animated:NO];
[self loadImageInNewThread];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:#"ht7" ofType:#"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
NSString *htmlString2 = [NSString stringWithFormat:htmlString,_restaurant.description];
self.webView.delegate=self;
[self.webView loadHTMLString:htmlString2 baseURL:nil];
_webView.opaque = NO;
_webView.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.306 green:0.306 blue:0.306 alpha:1];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar
setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO;
self.EntityPlot.delegate = self;
CLLocationCoordinate2D coordinate1 = CLLocationCoordinate2DMake(_restaurant.lattitude, _restaurant.longditude);
EntityPlot *coordinate2 = [[EntityPlot alloc] initWithTitle:decodedText Location:coordinate1];
[self.EntityPlot addAnnotation: coordinate2];
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = _restaurant.lattitude;
annotationCoord.longitude = _restaurant.longditude;
UIImage *image = [UIImage imageNamed:#"cream_pixels_#2X.png"];
self.uiView.backgroundColor = [UIColor colorWithPatternImage:image];
[_barplot setRegion:MKCoordinateRegionMake(annotationCoord, MKCoordinateSpanMake(.005, .005)) animated:YES];
[_barplot selectAnnotation:coordinate2 animated:YES];
_barplot.showsUserLocation = YES;
Me trying to implement:
//Pass string DMS for Lat and Long
- (double)DMSStringToDecimal:(NSString*)strDMS
{
// split the string
NSArray *arrSplit = [strDMS componentsSeparatedByString:#":"];
//direction
NSString *direction = [arrSplit objectAtIndex:0];
//degree
NSString *degreesString = [[[arrSplit objectAtIndex:1] componentsSeparatedByString:#" "] objectAtIndex:0];
NSArray *arrMinuteandSeconds=[[[[arrSplit objectAtIndex:1] componentsSeparatedByString:#" "] objectAtIndex:1] componentsSeparatedByString:#"."];
//minutes
NSString *minutesString = [arrMinuteandSeconds objectAtIndex:0];
//seconds
NSString *secondsString = [arrMinuteandSeconds objectAtIndex:1];
// convert degrees
double degrees = [degreesString doubleValue];
// convert minutes
double minutes = [minutesString doubleValue] / 60; // 60 degrees in a minute
// convert seconds
double seconds = [secondsString doubleValue] / 3600; // 60 seconds in a minute, or 3600 in a degree
// add them all together
double decimal = degrees + minutes + seconds;
// determine if this is negative. south and west would be negative values
if ([direction.uppercaseString isEqualToString:#"W"] || [direction.uppercaseString isEqualToString:#"S"])
{
decimal = -decimal;
}
return decimal;
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *decodedText1 = [_restaurant.name stringByReplacingOccurrencesOfString:#"’" withString:#"'"];
NSString *decodedText = [decodedText1
stringByReplacingOccurrencesOfString:#"&" withString:#"&"];
self.title = _restaurant.type;
self.barname.text = decodedText;
self.address.text = _restaurant.location;
[[self navigationController] setNavigationBarHidden:NO animated:NO];
[self loadImageInNewThread];
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:#"ht7" ofType:#"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
NSString *htmlString2 = [NSString stringWithFormat:htmlString,_restaurant.description];
self.webView.delegate=self;
[self.webView loadHTMLString:htmlString2 baseURL:nil];
_webView.opaque = NO;
_webView.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.306 green:0.306 blue:0.306 alpha:1];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar
setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO;
self.EntityPlot.delegate = self;
// location crap
NSString *latStr = [NSString stringWithFormat:htmlString,_restaurant.lattitude];
NSString *lonStr = [NSString stringWithFormat:htmlString,_restaurant.longditude];
double lat = [self DMSStringToDecimal:latStr]; //which gives lat=-35.018055555555556
double lon = [self DMSStringToDecimal:lonStr]; //which gives lon=148.28333333333333
// CLLocation *loc = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
CLLocationCoordinate2D coordinate1 = CLLocationCoordinate2DMake(lat, lon);
EntityPlot *coordinate2 = [[EntityPlot alloc] initWithTitle:decodedText Location:coordinate1];
// CLLocationCoordinate2D coordinate1 = CLLocationCoordinate2DMake(_restaurant.lattitude, _restaurant.longditude);
// EntityPlot *coordinate2 = [[EntityPlot alloc] initWithTitle:decodedText Location:coordinate1];
[self.EntityPlot addAnnotation: coordinate2];
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = lat;
annotationCoord.longitude = lon;
// annotationCoord.latitude = _restaurant.lattitude;
// annotationCoord.longitude = _restaurant.longditude;
UIImage *image = [UIImage imageNamed:#"cream_pixels_#2X.png"];
self.uiView.backgroundColor = [UIColor colorWithPatternImage:image];
[_barplot setRegion:MKCoordinateRegionMake(annotationCoord, MKCoordinateSpanMake(.005, .005)) animated:YES];
[_barplot selectAnnotation:coordinate2 animated:YES];
_barplot.showsUserLocation = YES;
}
May be you can do something like below, (from answer: https://stackoverflow.com/a/28545279/5575752):
NSString *latStr=#"S:35 00.065";
NSString *lonStr=#"E:148 06.660";
double lat = [self DMSStringToDecimal:latStr]; //which gives lat=-35.018055555555556
double lon = [self DMSStringToDecimal:lonStr]; //which gives lon=148.28333333333333
// Now create Location object
CLLocation *loc = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
//Pass string DMS for Lat and Long
- (double)DMSStringToDecimal:(NSString*)strDMS
{
// split the string
NSArray *arrSplit = [strDMS componentsSeparatedByString:#":"];
//direction
NSString *direction = [arrSplit objectAtIndex:0];
//degree
NSString *degreesString = [[[arrSplit objectAtIndex:1] componentsSeparatedByString:#" "] objectAtIndex:0];
NSArray *arrMinuteandSeconds=[[[[arrSplit objectAtIndex:1] componentsSeparatedByString:#" "] objectAtIndex:1] componentsSeparatedByString:#"."];
//minutes
NSString *minutesString = [arrMinuteandSeconds objectAtIndex:0];
//seconds
NSString *secondsString = [arrMinuteandSeconds objectAtIndex:1];
// convert degrees
double degrees = [degreesString doubleValue];
// convert minutes
double minutes = [minutesString doubleValue] / 60; // 60 degrees in a minute
// convert seconds
double seconds = [secondsString doubleValue] / 3600; // 60 seconds in a minute, or 3600 in a degree
// add them all together
double decimal = degrees + minutes + seconds;
// determine if this is negative. south and west would be negative values
if ([direction.uppercaseString isEqualToString:#"W"] || [direction.uppercaseString isEqualToString:#"S"])
{
decimal = -decimal;
}
return decimal;
}
Do modifications as per your requirement.
Hope it will help:)
Related
Can someone confirm for me this is the correct way to convert a NSString to an NSDecimalNumber? I have a label where when you click the button the price shows up, which is called totalPriceCalculated and then I also have all the strings where the calculations are made. Thanks in advance!
- (IBAction)calculateTotalPrice:(id)sender {
NSString *priceStringOne = [hiddenPriceOneTF text];
float priceFloatOne = [priceStringOne NSNumberFormatter];
NSString *priceStringTwo = [hiddenPriceTwoTF text];
float priceFloatTwo = [priceStringTwo floatValue];
NSString *priceStringThree = [hiddenPriceThreeTF text];
float priceFloatThree = [priceStringThree floatValue];
NSString *priceStringFour = [hiddenPriceFourTF text];
float priceFloatFour = [priceStringFour floatValue];
NSString *quanityStringOne = [quanityFirstTF text];
float quanityFloatOne = [quanityStringOne floatValue];
NSString *quanityStringTwo = [quanitySecondTF text];
float quanityFloatTwo = [quanityStringTwo floatValue];
NSString *quanityStringThree = [quanityThirdTF text];
float quanityFloatThree = [quanityStringThree floatValue];
NSString *quanityStringFour = [quanityFourthTF text];
float quanityFloatFour = [quanityStringFour floatValue];
float totalAmount = priceFloatOne * quanityFloatOne + priceFloatTwo * quanityFloatTwo + priceFloatThree * quanityFloatThree + priceFloatFour * quanityFloatFour ;
NSString *result = [NSString stringWithFormat:#" $ %0.2f", totalAmount];
[totalPriceCalculated setText:result];
NSString *totalPrice = totalPriceCalculated.text;
NSDecimalNumber *totalPriceNumber = (NSDecimalNumber *)totalPrice;
}
NSString *priceStringOne = [hiddenPriceOneTF text];
float priceFloatOne = [priceStringOne NSNumberFormatter];
UPDATED*
PayPalPayment *payment = [[PayPalPayment alloc] init];
payment.amount = [NSDecimalNumber decimalNumberWithString:totalPriceNumber];
payment.currencyCode = #"USD";
payment.shortDescription = #"Hipster t-shirt";
Another option is to create the decimal number from the float:
NSDecimalNumber *totalPriceNumber = [NSDecimalNumber decimalNumberWithDecimal:[#(totalAmount) decimalValue]];
According to the Apple docs, the prefered way is to use +decimalNumberWithString:; hope that helps.
Try:
totalPriceNumber = [[NSDecimalNumber alloc] initWithFloat:totalAmount];
I have a map that displays an array of annotations. These annotations are all called from a plist and each have a date at which they occur. I would like these annotations to display only on the date that they happen, however I have no clue how to approach this. Any help would be much appreciated.
for (NSString *dateString in contentArray) {
[[NSUserDefaults standardUserDefaults] stringForKey:#"Date"];
}
This is the little bit of code I have written in but it does not solve anything for me.
EDIT:
Here is the code that calls the annotations generally.
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
indexValue = 0;
NSString* plistPath = [[NSBundle mainBundle] pathForResource:#"mapAddress" ofType:#"plist"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
NSString *strID = [NSString stringWithFormat:#"%d",intID];
NSLog(#"array : %#",[dict objectForKey:strID]);
[contentArray removeAllObjects];
[contentArray addObjectsFromArray:[dict objectForKey:strID]];
[contentArray retain];
[self zoomToUserLocation:mapViewuno.userLocation];
}
- (void)zoomToUserLocation:(MKUserLocation *)userLocation
{
if (!userLocation)
return;
MKCoordinateRegion region;
region.center = userLocation.location.coordinate;
region.span = MKCoordinateSpanMake(.5, .5);
region = [mapViewuno regionThatFits:region];
[mapViewuno setRegion:region animated:YES];
counter = 0;
[mapViewuno removeAnnotations:mapViewuno.annotations];
if([contentArray count] != 0)
{
for(indexValue = 0; indexValue<[contentArray count];indexValue++)
{
FirstAnnotation *obj=[[FirstAnnotation alloc]init];
obj.latitude = [[[contentArray objectAtIndex:indexValue] objectForKey:#"lattitude"] floatValue];
obj.longitude = [[[contentArray objectAtIndex:indexValue] objectForKey:#"Longitude"] floatValue];
obj.titleName=[[contentArray objectAtIndex:indexValue] objectForKey:#"Title"];
obj.Address = [[contentArray objectAtIndex:indexValue] objectForKey:#"Address"];
obj.Phone = [[contentArray objectAtIndex:indexValue] objectForKey:#"Phone"];
obj.intTag = indexValue;
[mapViewuno addAnnotation:obj];
}
if ([mapViewuno.annotations count] == 0) return;
// [self.mapView setRegion:newRegion animated:YES];
}
}
I am using the latest GoogleMaps iOS SDK in my application and after the latest iOS update, 7.0.3, it started becoming unresponsive after first touch. Let me expand on this. After the first touch on the map, the map becomes unresponsive. At first, you can pinch zoom, drag, swipe, and everything else but after that first touch, it no longer works. This started happening after Apple updated their iOS. If I use the iOS6 simulator, I can can do all the gestures even after the first touch. I don't know if this is because of the iOS update or something is wrong with my code. If anyone has any suggestions or has gone through something like this that could guide me, that could be greatly appreciated. Thanks in advance.
Followed the website instructions here: (https://developers.google.com/maps/documentation/ios/start#adding_the_google_maps_sdk_for_ios_to_your_project)
and it works on iOS6 and was working on iOS7 before.
MapsViewController.m
#import "MapsViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#interface MapsViewController ()
#end
#implementation MapsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.storeNamesArray = [[NSMutableArray alloc] init];
self.storePricesArray = [[NSMutableArray alloc] init];
self.storeLatitudeArray = [[NSMutableArray alloc] init];
self.storeLongitudeArray = [[NSMutableArray alloc] init];
self.priceTypeArray = [[NSMutableArray alloc] init];
dispatch_async(dispatch_get_main_queue(), ^{ NSData *data =
[NSData dataWithContentsOfURL:[NSURL URLWithString:
[NSString stringWithFormat: #"http://www.someurl.com/mobile-api"]]];
[self performSelectorOnMainThread:#selector(fetchData:) withObject:data
waitUntilDone:YES]; });
}
-(void)fetchData:(NSData *)responseData
{
if (responseData)
{
NSError *error;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSDictionary *stores =[json objectForKey:#"stores"];
for(NSDictionary *location in stores)
{
[self.storeNamesArray addObject:[location objectForKey:#"name"]];
[self.storePricesArray addObject:[location objectForKey:#"price"]];
[self.storeLatitudeArray addObject:[location objectForKey:#"latitude"]];
[self.storeLongitudeArray addObject:[location objectForKey:#"longitude"]];
[self.priceTypeArray addObject:[location objectForKey:#"price_type"]];
}
}
double lat = 0.0;
double lon = 0.0;
GMSCameraPosition *camera;
if(self.currentLocationArray.count !=0)
{
lat = [self.currentLocationArray[0] doubleValue];
lon = [self.currentLocationArray[1] doubleValue];
camera = [GMSCameraPosition cameraWithLatitude:lat longitude:lon zoom:12];
}
else
{
lat = [self.storeLatitudeArray[0] doubleValue];
lon = [self.storeLongitudeArray[0] doubleValue];
camera = [GMSCameraPosition cameraWithLatitude:lat longitude:lon zoom:9];
}
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
for(int i=0; i<self.storeNamesArray.count; i++)
{
GMSMarker *marker = [[GMSMarker alloc] init];
marker.title = self.storeNamesArray[i];
marker.snippet = [NSString stringWithFormat:#"%# $%#", self.priceTypeArray[i], self.storePricesArray[i]];
marker.position = CLLocationCoordinate2DMake([self.storeLatitudeArray[i] doubleValue], [self.storeLongitudeArray[i] doubleValue]);
marker.map = mapView;
}
if(self.currentLocationArray.count !=0)
{
GMSMarker *currentMarker = [[GMSMarker alloc] init];
currentMarker.title = #"Current Location";
currentMarker.snippet = #"You are here";
currentMarker.position = CLLocationCoordinate2DMake(lat, lon);
currentMarker.map = mapView;
currentMarker.icon = [UIImage imageNamed:#"temp_userLocation"];
mapView.selectedMarker = currentMarker;
}
CGRect newFrame = self.view.bounds;
newFrame.size.height = frame.size.height / 2;
mapView.frame = newFrame;
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
mapView.delegate = self;
[self.view addSubview:mapView];
}
I've published my reworked version of Chris's code on the Google Maps SDK for iOS bug.
The solution involved two changes to Chris's code:
Migrate the Google Map instantiation to viewDidLoad,
Push the network traffic from the Main (UI) thread to a background thread.
I don't know if that's the case here but I had same issue with URLWithString function appears only on iOS 7.0.3, I assume Apple has change the characters this function can use so if it returns nil this is your solution.
What I did is using this function to create the string before using it with URLWithString:
-(NSString *) URLEncodeString:(NSString *) str // New to fix 7.0.3 issue //
{
NSMutableString *tempStr = [NSMutableString stringWithString:str];
[tempStr replaceOccurrencesOfString:#" " withString:#"+" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [tempStr length])];
return [[NSString stringWithFormat:#"%#",tempStr] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
On your case just change the line to this one:
dispatch_async(dispatch_get_main_queue(), ^{ NSData *data =
[NSData dataWithContentsOfURL:[NSURL URLWithString:[self URLEncodeString: [NSString stringWithFormat: #"http://www.someurl.com/mobile-api"]]]];
[self performSelectorOnMainThread:#selector(fetchData:) withObject:data
waitUntilDone:YES]; });
Hope that would help you too.
insert this code in viewDidLoad method
-(void)viewDidLoad
{
[super viewDidLoad];
// iOS7
if ([self.navigationController respondsToSelector:#selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
.... your codes
}
Hello and Thanks for the help.
Is it possible to populate 10 mapview locations from a .plist file using a for loop ? If so how ?
my current code for my mapview is all hard coded. I would like to improve upon this by pulling - Longitude, Latitude, Title, SubTitle - from a for loop if possible. Thank You.
////
.....
MKCoordinateRegion region3 = {{0.0,0.0}, {0.0,0.0}};
region3.center.latitude = 33.45869;
region3.center.longitude = -84.66931;
region3.span.longitudeDelta = 0.01f;
region3.span.latitudeDelta=0.01f;
// [mapview setRegion:region4 animated:YES];
BandsMap *ann3 = [[BandsMap alloc]init];
ann3.title = #"Indigo Bar & Lounge";
ann3.subtitle = #"Let the good times roll";
ann3.coordinate = region3.center;//
////
annoArray = [[NSArray alloc] initWithObjects:ann1,ann2,ann3.....,nil];
[mapView addAnnotations:annoArray];.......
Something like this I suppose but not quite sure how to finish
for(NSDictionary *key in mapDataPlist)
{
NSString *c = [key objectForKey:#"Title"];
NSString *a = [key objectForKey:#"SubTitle"];
NSString *lat = [key objectForKey:#"Latitude"];
NSString *lon = [key objectForKey:#"Longitude"];
CGFloat strFLat = (CGFloat)[lat floatValue];
CGFloat strFLon = (CGFloat)[lon floatValue];
//////
?????
}
Just iterate over your plist array and use the code you have to create the regions from the extracted data. Then, instead of annoArray being an array you create at the end, make it a mutable array and add each item at the end of each loop iteration.
[mapView setRegion:adjustedRegion animated:YES];
mapView.mapType=MKMapTypeStandard;
UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
tableView.dataSource = self;
tableView.delegate = self;
tableView.frame = CGRectMake(28, 60, 334, 649);
[self.view addSubview:tableView];
NSString *path = [[NSBundle mainBundle] pathForResource:
#"CityList" ofType:#"plist"];
NSMutableArray *cities = [[NSMutableArray alloc] initWithContentsOfFile:path];
NSMutableArray *localCities= [[NSMutableArray alloc]init];
for (int i=0;i<[cities count];i++)
{
NSLog(#"%#",[[cities objectAtIndex:i]objectForKey:#"cityNameKey"]);
[localCities addObject:[[cities objectAtIndex:i]objectForKey:#"cityNameKey"]];
}
locationArray= localCities;
Annotation *annotation=[[Annotation alloc]init];
annotation.coordinate = CLLocationCoordinate2DMake(29.7631,-95.3631);
annotation.color = [UIColor redColor];
annotation.title=[NSString stringWithFormat:#"Houston"];
[mapView addAnnotation:annotation];
The code should do an adress search. The line CLLocationCoordinate2D location2 = [self adressLocation isn't working. It's saying "Invalid Initializer". What could be wrong?
-(IBAction) search {
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 0.4;
span.longitudeDelta = 0.4;
CLLocationCoordinate2D location2 = [self adressLocation];
region.span = span;
region.center = location2;
Mark adr = [[Mark alloc] initWithCoordinate:location2];
[mapView addAnnotation:adr];
}
-(CLLocationCoordinate2D) adressLocation {
NSString * urlString = [NSString stringWithFormat:#"http://maps.google.com/maps/geo?q=%#&output=csv",[suchFeld.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString * locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSUTF8StringEncoding error:&fileError];
NSArray * listItems = [locationString componentsSeparatedByString:#","];
double latitude2 = 0.0;
double longitude2 = 0.0;
if ([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:#"200"])
{
latitude2 = [[listItems objectAtIndex:2] doubleValue];
longitude2 = [[listItems objectAtIndex:3] doubleValue];
} else {
// error
CLLocationCoordinate2D location2;
location2.latitude = latitude2;
location2.longitude = longitude2;
return location2;
}
The adressLocation method is probably not declared in the .h file and since the method is defined after the code calling it, the compiler gives that error. Add this to the .h file:
-(CLLocationCoordinate2D) adressLocation;
Some separate issues:
In the search method, you have Mark adr = [[Mark alloc]....
This should be Mark *adr = [[Mark alloc]... (note asterisk).
Also in the search method, you need to do [adr release]; after the addAnnotation line.
Finally, adressLocation does not return a value in all cases.
It only does a return in the else-part. It needs to return a value in the if-part also.