简体   繁体   中英

creating a function in Objective-C

I'm a newbie in Objective-C, and I'm trying to add Markers to a mapView in my Apple app.

In my class Map, I'm trying to add a function wich adds markers.

In Map.h I add:

- (void)setMarkers:(MKMapView *)mv;

And in Map.m:

- (void)setMarkers:(MKMapView *)mv
{

CLLocationCoordinate2D newCoord = { 38.989567, -1.856283};
MapPoint *mp = [[MapPoint alloc] initWithCoordinate:newCoord title:[NSString stringWithFormat:@"Azam Home"] subTitle:@"Home Sweet Home"];
[mv addAnnotation:mp];

}

But when I try to call this function:

[setMarkers mv:map];

I have this error:

Map.m:278:6: Use of undeclared identifier 'setMarkers'

What am I missing?

Thank you in advance.

您缺少self

[self setMarkers:mv];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM