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

Thread: MKAnnotation
View Single Post
Old 07-29-2010, 07:35 PM   #9 (permalink)
Ovidius
Registered Member
 
Ovidius's Avatar
 
Join Date: Jun 2010
Posts: 77
Ovidius is on a distinguished road
Default

Quote:
Originally Posted by Ovidius View Post
No worries, but I do get some errors which I don't know how to deal with:

Code:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)anAnnotation 
{
	if ([anAnnotation isKindOfClass:MapAnnotation]) <- expected expression before 'MapAnnotation'



	{
		MapAnnotation *theAnnotation = [[MapAnnotation alloc] init];
		theAnnotation = (MapAnnotation *)anAnnotation; <- 'theAnnotation' undeclared (first use in this function)



		if (theAnnotation.identifier == @"StartAnnotation")
		{
			MKPinAnnotationView *startAnnotationPin = [[MKPinAnnotationView alloc] initWithAnnotation:anAnnotation reuseIdentifier:@"StartPin"];
			startAnnotationPin.pinColor = MKPinAnnotationColorGreen;
			return startAnnotationPin;
		}
		return nil;
	}
} <-- control reaches end of non-void function
OK I got it now, for those who may want the same answer:

Code:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)anAnnotation 
{
	if ([anAnnotation isKindOfClass:[MapAnnotation class]])
	{
		MapAnnotation *theAnnotation = (MapAnnotation *)anAnnotation;
		if (theAnnotation.identifier == @"StartAnnotation")
		{
			MKPinAnnotationView *startAnnotationPin = [[MKPinAnnotationView alloc] initWithAnnotation:anAnnotation reuseIdentifier:@"StartPin"];
			startAnnotationPin.pinColor = MKPinAnnotationColorGreen;
			return startAnnotationPin;
		}
	}
	return nil;
}
I guess I should note I included an NSString named identifier in the class of MapAnnotation...

Duncan, thanks so much for your help, it went a long way. I never did map annotations until now, and the way they are implemented in the framework is extremely weird IMHO, but anyways, thank you. Without your guidance I don't know how else I could have understood the MKAnnotation class.

Last edited by Ovidius; 07-29-2010 at 07:39 PM.
Ovidius is offline   Reply With Quote
 

» Advertisements
» Online Users: 374
10 members and 364 guests
amit.mangal, Domele, HemiMG, ipodphone, minglei, online-loans70, PavelSea, Sesio, thephotographer, Wharazhasri
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,568
Threads: 94,081
Posts: 402,751
Top Poster: BrianSlick (7,990)
Welcome to our newest member, online-loans70
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:24 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.