I'm using an NSDictionary to populate data for my MapView annotations. However, when I tap on my MapView annotation, the detailView should display the selected user's information. That said, right now, when I tap an annotation, all detailViews display the same user's information (even though the details in the actual annotation's display bubble are correct). How can I fix this? Why won't NSDictionary allow me to do this?
MapViewController.m
NSMutableDictionary *viewParams = [NSMutableDictionary new];
[viewParams setValue:#"u000" forKey:#"view_name"];
[DIOSView viewGet:viewParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.addressData = [responseObject mutableCopy];
for (NSMutableDictionary *multiplelocations in self.addressData) {
NSString *location = multiplelocations[#"street_address"];
NSLog(#"Pull addresses %#", location);
NSString *userNames = multiplelocations[#"users_name"];
NSString *userBio = multiplelocations[#"userbio"];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray* placemarks, NSError* error){
if (placemarks && placemarks.count > 0) {
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];
MKCoordinateRegion region = self.mapView.region;
region.span.longitudeDelta /= 8.0;
region.span.latitudeDelta /= 8.0;
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = placemark.coordinate;
point.title = userNames;
point.subtitle = userBio;
[self.mapView addAnnotation:point];
}
}
];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Failure: %#", [error localizedDescription]);
}];
}
-(void)calloutTapped:(UITapGestureRecognizer *) sender
{
NSLog(#"Callout was tapped");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
OtherUserViewController *yourViewController = (OtherUserViewController *)[storyboard instantiateViewControllerWithIdentifier:#"OtherUserViewController"];
NSDictionary *dictionary = [[NSDictionary alloc] init];
dictionary = [[self.addressData firstObject] mutableCopy];
yourViewController.mapuserData = dictionary;
[self.navigationController pushViewController:yourViewController animated:YES];
}
self.addressData via console
{
address = "1300 Fake Street, Vancouver, BC";
childrenunder = No;
city = Va;
"emergency facility" = Yes;
"first name" = Admin;
"last name" = Account;
phone = "Not Available";
"photo_path" = "http://myurl.com/files/stored/1461176121.jpg";
"postal code" = V6B0L1;
"profile photo" = "<img typeof=\"foaf:Image\" src=\"stored/1461176121.jpg\" width=\"300\" height=\"300\" alt=\"\" />";
"property type" = House;
province = B;
"street_address" = "1300 Fake Street, Vancouver, BC";
supervision = Yes;
uid = 1;
userbio = "Need assistance? This account belongs to the team! Message us if you have any questions.";
"users_name" = Britt;
}
)
dictionary = [[self.addressData firstObject] mutableCopy];
Are you serious?
This should be
NSMutableDictionary *dictionary = [self.addressData mutableCopy];
While navigating to detail view controller, you are always getting the first object from the dictionary array.
[[self.addressData firstObject] mutableCopy];
Thats the reason you are getting the same information for all the annotation view.
Instead of that line of code, You have to identify which map marker is clicked on the MapView, for example identify the index of the dictionary array. Pick the dictionary from the array and pass it to the detail view.
Related
I'm passing data from my ViewController to a detailViewController with the below code, however no matter what I seem to do, my app crashes at the line
self.username.text = self.mapuserData[#"users_name"];
with the following error (even though data is present in self.mapuserData)? Help!
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSArrayI
objectForKeyedSubscript:]: unrecognized selector sent to instance
0x17126b840'
ViewController.m
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(calloutTapped:)];
[view addGestureRecognizer:tapGesture];
}
-(void)calloutTapped:(UITapGestureRecognizer *) sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
OtherUserViewController *yourViewController = (OtherUserViewController *)[storyboard instantiateViewControllerWithIdentifier:#"OtherUserViewController"];
NSMutableDictionary *dictionary = [self.addressData mutableCopy];
yourViewController.mapuserData = dictionary; // this is how you do it
[self.navigationController pushViewController:yourViewController animated:YES];
}
OtherViewController.m (detailview)
- (void)viewDidLoad {
[super viewDidLoad];
if ([self.mapuserData count] > 0) {
NSLog(#"This is map user data %#", self.mapuserData);
self.addFriend.hidden = NO;
self.username.text = self.mapuserData[#"users_name"];
self.userBio.text = self.mapuserData[#"userbio"];
NSString *thirdLink = self.mapuserData[#"photo_path"];
NSString *ImageURLTwo = thirdLink;
NSData *imageDataTwo = [NSData dataWithContentsOfURL:[NSURL URLWithString:ImageURLTwo]];
self.userPhoto.image = [[UIImage alloc] initWithData:imageDataTwo];
}
}
Here's what's in self.mapuserData:
This is map user data (
{
address = "2957 fake street";
childrenunder = Yes;
city = Vancouver;
"emergency facility" = None;
"first name" = josh;
"last name" = tree;
phone = 6046710890;
"photo_path" = "http://url.ca/paw.png";
"points balance" = 24;
"postal code" = b6b6v5;
"profile photo" = "<null>";
"property type" = Apartment;
province = bc;
"special skills" = "Medication";
"star rating" = 0;
"street_address" = none;
supervision = Yes;
uid = 182;
userbio = nfkkdkckmfkekxkx;
"users_name" = "josh_tree#hotmail.com";
Create your own class to store index of the Annotation data source. Which is subclass of MKPointAnnotation
PointAnnotation.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface PointAnnotation : MKPointAnnotation
#property (nonatomic, assign)int index;
#end
PointAnnotation.m
#import "PointAnnotation.h"
#implementation PointAnnotation
#end
Change your Add Annotation code like below
int index = 0; //Index to track the data source index while select the annotation call out view.
for (NSMutableDictionary *multiplelocations in self.addressData) {
NSString *location = multiplelocations[#"street_address"];
NSLog(#"Pull addresses %#", location);
NSString *userNames = multiplelocations[#"users_name"];
NSString *userBio = multiplelocations[#"userbio"];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray* placemarks, NSError* error){
if (placemarks && placemarks.count > 0) {
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];
MKCoordinateRegion region = self.mapView.region;
region.span.longitudeDelta /= 8.0;
region.span.latitudeDelta /= 8.0;
PointAnnotation *point = [[PointAnnotation alloc] init];
point.coordinate = placemark.coordinate;
point.title = userNames;
point.subtitle = userBio;
point.index = index; // Store index here.
[self.mapView addAnnotation:point];
}
}
];
index = index + 1;
}
And modify your didSelectAnnotationView code like below
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
//Get the annotation object from callout view.
PointAnnotation *selectedPoint = (PointAnnotation *) view.annotation;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
OtherUserViewController *yourViewController = (OtherUserViewController *)[storyboard instantiateViewControllerWithIdentifier:#"OtherUserViewController"];
//Get the dictionary from array by using the index of the custom PointAnnoation object.
NSMutableDictionary *dictionary = self.addressData[selectedPoint.index];
yourViewController.mapuserData = dictionary;
[self.navigationController pushViewController:yourViewController animated:YES];
}
You are assigning an Array to Dictionary which is wrong.
NSMutableDictionary *dictionary = [self.addressData mutableCopy];
yourViewController.mapuserData = dictionary;
The Dictionary you are expecting is the array type at the run time so you need change the code above
NSMutableDictionary *dictionary = [self.addressData[0] mutableCopy];
change addressData to NSArray
self.mapuserData is no more deserializes into dictionary, It is deserializes into array.
So what you want to do is:
Get an object from zero index form self.mapuserData and then save as dictionary.
Example : NSDictionary *dict = self.mapuserData[0];
self.mapuserData should be type of array.
I am new in iOS and I am facing problem regarding to get current value of string from array.
My code is like this
loginStatusHS = [[NSString alloc] initWithBytes: [myNSMDatalatetudeFromServer mutableBytes] length:[myNSMDatalatetudeFromServer length] encoding:NSUTF8StringEncoding];
NSLog(#"loginStatus =%#",loginStatusHS);
NSError *parseError = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:loginStatusHS error:&parseError];
NSLog(#"JSON DICTIONARY = %#",xmlDictionary);
recordResultHS = [xmlDictionary[#"success"] integerValue];
NSLog(#"Success: %ld",(long)recordResultHS);
NSDictionary* Address=[xmlDictionary objectForKey:#"soap:Envelope"];
NSLog(#"Address Dict = %#",Address);
NSDictionary *new =[Address objectForKey:#"soap:Body"];
NSLog(#"NEW DICT =%#",new);
NSDictionary *LoginResponse=[new objectForKey:#"HS_GetResponse"];
NSLog(#"Login Response DICT =%#",LoginResponse);
NSDictionary *LoginResult=[LoginResponse objectForKey:#"HS_GetResult"];
NSLog(#"Login Result =%#",LoginResult);
if(LoginResult.count>0)
{
NSLog(#"Login Result = %#",LoginResult);
NSLog(#"Login Result Dict =%#",LoginResult);
NSString *teststr =[[NSString alloc] init];
teststr =[LoginResult objectForKey:#"text"];
NSLog(#"Test String Value =%#",teststr);
NSString *string = [LoginResult valueForKey:#"text"];
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
responseletetudedict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(#"Latetude Dictionary =%#",responseletetudedict);
idlatetudearray=[[NSMutableArray alloc]init];
idlatetudearray=[responseletetudedict valueForKey:#"City"];
NameHSArray=[[NSMutableArray alloc] init];
NameHSArray=[responseletetudedict valueForKey:#"Name"];
AddressHSArray=[[NSMutableArray alloc] init];
AddressHSArray=[responseletetudedict valueForKey:#"Address"];
FacilitiesHSArray=[[NSMutableArray alloc] init];
FacilitiesHSArray=[responseletetudedict valueForKey:#"Facilities"];
PhoneNoHSArray=[[NSMutableArray alloc] init];
PhoneNoHSArray=[responseletetudedict valueForKey:#"Phoneno"];
FaxnoHSArray=[[NSMutableArray alloc] init];
FaxnoHSArray=[responseletetudedict valueForKey:#"Faxno"];
LatitudeHSArray=[[NSMutableArray alloc] init];
LatitudeHSArray=[responseletetudedict valueForKey:#"Latitude"];
LongitudeHSArray=[[NSMutableArray alloc] init];
LongitudeHSArray=[responseletetudedict valueForKey:#"Longitude"];
TypeHSArray=[[NSMutableArray alloc] init];
TypeHSArray=[responseletetudedict valueForKey:#"Type"];
for (int i=0; i<NameHSArray.count; i++) {
double LatitudeDouble = [LatitudeHSArray[i] doubleValue];
double LongitudeDouble = [LongitudeHSArray[i] doubleValue];
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(LatitudeDouble, LongitudeDouble);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = NameHSArray[i];
marker.snippet=AddressHSArray[i];
userData = [[NSArray alloc] initWithObjects:NameHSArray[i], AddressHSArray[i],FacilitiesHSArray[i], PhoneNoHSArray[i],FaxnoHSArray[i], TypeHSArray[i], nil];
marker.userData = userData;
if([TypeHSArray[i] isEqualToString:#"ESIC"])
{
marker.icon = [UIImage imageNamed:#"mapicon2.png"];
}
else
{
marker.icon = [UIImage imageNamed:#"mapicon1.png"];
}
GMSCameraUpdate *zoomCamera = [GMSCameraUpdate zoomIn];
[mapView animateWithCameraUpdate:zoomCamera];
marker.map = mapView;
}
Add in the Image when I click on Nobel Hospital I call the delegate
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
// your click action
StringAddress = marker.snippet;
StringName = marker.title;
NSLog(#"Address=%#",StringAddress);
NSLog(#"Name= %#",StringName);
lblNamepopup.text=StringName;
lblAddresspopup.text=StringAddress;
NSLog(#"User Data Array = %#",userData);
viewpopup.hidden=NO;
viewpopup.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
viewpopup.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished){
// do something once the animation finishes, put it here
}];
}
Hear in this delegate I need to get the current name of string address.But hear I am getting the Last value means the string get override. How can I get the value which I have click from array. Thanks in Advance!
You can get index as follow
-(void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker
{
NSInteger index = [NameHSArray indexOfObject:marker.title];
NSLog(#"%ld",(long)index);
}
--- EDIT ---
You can also use
i found some reference from library.
Note that userData should not hold any strong references to any Maps
objects, otherwise a loop may be created (preventing ARC from releasing
objects).
NOTE :-
You can pass data through snippet but snippet show data into info window. so you creates a custom info window and show data as you want.
like this,
NSArray * userData = [NSArray alloc] initWithObjects:FacilitiesHSArray[i], PhoneNoHSArray[i],FaxnoHSArray[i], nil];
NSString *userDataString = [userData componentsJoinedByString:#";"];
marker.snippet = userDataString;
retrive
like this,
NSString *userDataString = marker.snippet;
NSArray *array = [userDataString componentsSeparatedByString:#";"];
NSLog(#"%#",array);
You can Do Like this
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
// your click action
StringAddress = marker.snippet;
StringName = marker.title;
NSInteger indexCheck = [NameHSArray indexOfObject:marker.title];
NSLog(#"Curret Index =%ld",(long)indexCheck);
StringName=[NSString stringWithFormat:#"%#",[NameHSArray objectAtIndex:indexCheck]];
StringAddress=[NSString stringWithFormat:#"%#",[AddressHSArray objectAtIndex:indexCheck]];
StringPhoneNo=[NSString stringWithFormat:#"%#",[PhoneNoHSArray objectAtIndex:indexCheck]];
NSLog(#"Address=%#",StringAddress);
NSLog(#"Name= %#",StringName);
NSLog(#"Phone No =%#",StringPhoneNo);
lblNamepopup.text=StringName;
lblAddresspopup.text=StringAddress;
}
I'm using the below code to display addresses from an array (responseObject) as annotations on my mapview. It works, and the pin is dropped successfully from my location string, however it only shows a pin for the most recent address added to the array. How can I change my code so that it shows pins on the map for all addresses in my array instead of just the most recent one? Apologies if this is a newb question. Thanks!
viewcontroller.m
NSMutableDictionary *viewParams = [NSMutableDictionary new];
[viewParams setValue:#"u000" forKey:#"view_name"];
[DIOSView viewGet:viewParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.addressData = [responseObject mutableCopy];
NSString *location = self.addressData[0][#"address"];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray* placemarks, NSError* error){
if (placemarks && placemarks.count > 0) {
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];
MKCoordinateRegion region = self.mapView.region;
// region.center = placemark.region.center;
region.span.longitudeDelta /= 8.0;
region.span.latitudeDelta /= 8.0;
[self.mapView setRegion:region animated:YES];
[self.mapView addAnnotation:placemark];
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = placemark.coordinate;
point.title = self.addressData[0][#"users_name"];
point.subtitle = self.addressData[0][#"userbio"];
[self.mapView addAnnotation:point];
You are accessing only one object ?
NSString *location = self.addressData[0][#"address"];
Edited
I think you should handle your data, separated with your view. i.e. implement geocoder related code in the mapView:viewForAnnotation: method in your map view delegate. Then you should be able to create the annotations one by one and use [self.mapView addAnnotations] for all of them
For your code, which I believe is inspired by this answer, you should be able to iterate through all location addresses by something like
for (NSMutableDictionary *loc in self.addressData) {
NSString *loc = location[#"address"];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
......
}
Forgive me if the syntax is wrong for Objective C.
I have develop an application in iOS 7.0. I have a map view in which user can see search results in map by means of annotation pins.
I have used custom annotation for that, For the first time annotations were placed at correct co ordinates. I mean at user location co ordinates were place at correct position.
But if i scroll map and search for location then it shows me annotation at wrong co ordinates.
Below is my code when user search any thing in map. (e.g Hotels, Museum, Restaurants)
- (void) searchForPlace:(NSString *) keyWord {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[self.activityView setHidden:NO];
[self.txtSearch resignFirstResponder];
[self.txtSearch setEnabled:NO];
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = keyWord; // #"restaurant"
MKCoordinateSpan span = MKCoordinateSpanMake(.1, .1);
CLLocationCoordinate2D location = self.mapView.userLocation.coordinate;
request.region = MKCoordinateRegionMake(location, span);
MKLocalSearch *search = [[MKLocalSearch alloc] initWithRequest:request];
[search startWithCompletionHandler:
^(MKLocalSearchResponse *response, NSError *error) {
[self.txtSearch setEnabled:YES];
[self removeMapOverlay];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[self.activityView setHidden:YES];
if (!error) {
// Result found
#try {
if (response.mapItems && [response.mapItems count] > 0) {
for (MKMapItem *item in response.mapItems) {
MKPlacemark *placeMark = item.placemark;
// Address details
NSDictionary *address = placeMark.addressDictionary;
NSString *titleString = #"";
NSString *subtitleString = #"";
NSString *name = #"";
NSString *Thoroughfare = #"";
NSString *State = #"";
NSString *City = #"";
NSString *Country = #"";
name = [address objectForKey:#"Name"] ? [address objectForKey:#"Name"] : #"";
Thoroughfare = [address objectForKey:#"Thoroughfare"] ? [address objectForKey:#"Thoroughfare"] : #"";
State = [address objectForKey:#"State"] ? [address objectForKey:#"State"] : #"";
City = [address objectForKey:#"City"] ? [address objectForKey:#"City"] : #"";
Country = [address objectForKey:#"Country"] ? [address objectForKey:#"Country"] : #"";
titleString = [NSString stringWithFormat:#"%# %#", name, Thoroughfare];
subtitleString = [NSString stringWithFormat:#"%# %# %#", State, City, Country];
CustomAnnotation *annotation = [[CustomAnnotation alloc] initWithTitle:titleString subTitle:subtitleString detailURL:item.url location:placeMark.location.coordinate];
[self.mapView addAnnotation:annotation];
}
[self mapView:self.mapView regionDidChangeAnimated:YES];
}
}
#catch (NSException *exception) {
NSLog(#"Exception :%#",exception.description);
}
} else {
NSLog(#"No result found.");
}
}];
}
I think it is because of this line:
CLLocationCoordinate2D location = self.mapView.userLocation.coordinate;
What here problem is you are doing search request for region around your user location.
You need to set center co ordinates region of MKMapView. So that region for the search area will be consider where ever you scroll in map.
Change above line with this and check your search result.
CLLocationCoordinate2D location = self.mapView.centerCoordinate;
I need to change the color and in some positions i need to set images for the annotation point. My code only displays red color Annotation please guide me my code is bellow,
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//MAP VIEW WebService
// NSLog(#"%#",nam2);
NSString *urlMapString=[NSString stringWithFormat:#"http://www.tranzlogix.com/tranzlogix_webservice/map.php?format=json&truckno=%#",nam2];
NSURL *urlMap=[NSURL URLWithString:urlMapString];
NSData *dataMap=[NSData dataWithContentsOfURL:urlMap];
NSError *errorMap;
NSDictionary *jsonMap = [NSJSONSerialization JSONObjectWithData:dataMap options:kNilOptions error:&errorMap]; NSArray *resultsMap = [jsonMap valueForKey:#"posts"];
NSArray *resMap = [resultsMap valueForKey:#"post"];
NSArray *latitudeString=[resMap valueForKey:#"latitude"];
// NSLog(#"%#", latitudeString);
NSString *latOrgstring = [latitudeString objectAtIndex:0];
// NSLog(#"%#", latOrgstring);
double latitude=[latOrgstring doubleValue];
NSArray *longitudeString=[resMap valueForKey:#"longitude"];
// NSLog(#"%#", longitudeString);
NSString *longOrgstring = [longitudeString objectAtIndex:0];
// NSLog(#"%#", longOrgstring);
double longitude=[longOrgstring doubleValue];
// NSLog(#"latdouble: %f", longitude);
//MAP VIEW Point
MKCoordinateRegion myRegion;
//Center
CLLocationCoordinate2D center;
center.latitude=latitude;
center.longitude=longitude;
//Span
MKCoordinateSpan span;
span.latitudeDelta=THE_SPAN;
span.longitudeDelta=THE_SPAN;
myRegion.center=center;
myRegion.span=span;
//Set our mapView
[MapViewC setRegion:myRegion animated:YES];
//Annotation
//1.create coordinate for use with the annotation
CLLocationCoordinate2D wimbLocation;
wimbLocation.latitude=latitude;
wimbLocation.longitude=longitude;
Annotation * myAnnotation= [Annotation alloc];
CLLocation *someLocation=[[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:someLocation completionHandler:^(NSArray *placemarks, NSError *error) {
NSDictionary *dictionary = [[placemarks objectAtIndex:0] addressDictionary];
// NSLog(#"%#",dictionary);
addressOutlet=[dictionary valueForKey:#"Street"];
// NSLog(#"%#",addressOutlet);
City=[dictionary valueForKey:#"City"];
// NSLog(#"%#",City);
State=[dictionary valueForKey:#"State"];
// NSLog(#"%#",State);
myAnnotation.coordinate=wimbLocation;
if (addressOutlet!=NULL&&City!=NULL)
{
myAnnotation.title=addressOutlet;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#,%#", City, State];
}
else if (addressOutlet==NULL&&City!=NULL)
{
myAnnotation.title=City;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#,%#", City, State];
}
else if (addressOutlet!=NULL&&City==NULL)
{
myAnnotation.title=addressOutlet;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#", State];
}
else if(addressOutlet==NULL&&City==NULL)
{
myAnnotation.title=State;
myAnnotation.subtitle=[NSString stringWithFormat:#"%#",State];
}
[self.MapViewC addAnnotation:myAnnotation];
}];
}
Please guide me i am very new to xcode & objective-c
You need to subclass the MKAnnotationView and override a couple of properties and methods to set an image of your preference. Since thats just too much of a walk through I managed to fish out a blog to help you do that.