Why are you trying to modify the framework? You should be defining itemID
as a property or instance variable (or both) in myAnnotation.h
. You say that currentAnnotation.itemTag
didn't work; for that to work, you need to have itemTag
defined as a property of whatever class currentAnnotation
belongs to.
Changing the header file for the framework won't recompile it, so you won't be able to get that to work.
EDIT: Here's an example.
In MyAnnotation.h
:
@interface MyAnnotation : NSObject <MKAnnotation> {
NSString *itemID;
// Other instance variables
}
@property (nonatomic, retain) NSString *itemID;
// Class and instance methods.
@end
In MyAnnotation.m
:
@implementation MyAnnotation
@synthesize itemID;
// Your code here.
@end
The @property
call defines the property and the @synthesize
call will create setters and getters for you (methods to set and retrieve the value of itemID
). In MyAnnotation.m
, you can use self.itemID
or [self itemID]
to get the value of itemID
, and you can use self.itemID = @"something"
or [self setItemID:@"Something"]
to set the value.
EDIT 2:
When you get currentAnnotation
, if the compiler doesn't know that the annotation is an instance of your MyAnnotation class, it won't know about itemID
. So, first ensure that you've included this line at the beginning of your .m
file:
#import MyAnnotation.h
That wil ensure that the compiler knows about the class. When you use currentAnnotation
, you cast it as an instance of MyAnnotation
like so:
(MyAnnotation*)currentAnnotation
That should quiet down the warnings.