Sam Cromer
Sam Cromer

Reputation: 707

MapAnnotations iOS 7+

Are there any other fields that can be added to a MapAnnotation other than setTitle and setSubtitle? I want to add more information to it than just 2 bits of data.

EDIT

I am looking for iOS 7+ info on this.

Upvotes: 0

Views: 45

Answers (1)

nevan king
nevan king

Reputation: 113777

MKAnnotation is a protocol, so you can make any class into an annotation by making it conform to that protocol. As long as that class fulfils the requirements (title, subtitle and coordinate) you can add whatever properties you want. None of this has changed in iOS 7.

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>

@interface Shop : NSObject <MKAnnotation, NSCoding>

@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;

@property (nonatomic, assign) int shopId;
@property (nonatomic, copy) NSString *shopOwnerName;

@end

Upvotes: 1

Related Questions