How to change the name of UIBarButtonItem - iPhone SDK
Can someone help me with the fact that I am only trying to change Title to UIBarButtonItem from another class.
My code:
- (IBAction) spanishPush {
SafetyTalks *bbiTitle = [[SafetyTalks alloc] init];
bbiTitle.bbiOpenPopOver.title = @"Spanish";
}
SafetyTalks = the class I'm trying to use bbiOpenPopOver = UIBarButtonItem.
I can change the Title when in the SafetyTalks class just:
bbiOpenPopOver.title = @"Talk Topics";
but can't do it when i got out of this class.
Please, help.
Andy
+2
a source to share
1 answer
What you can do is define a property on the class SafetyTalks
. Declare it and provide a custom getter and setter. This way the title can be retrieved and set outside of the class.
In your header file add:
@interface SafetyTalks : ... {
// ....
}
// ....
@property (assign) NSString *title;
// ....
@end
In your source file add:
@implementation SafetyTalks
// ....
- (NSString *)title {
return self.bbiOpenPopOver.title;
}
- (void)setTitle:(NSString *) value {
self.bbiOpenPopOver.title = value;
}
// ....
@end
+1
a source to share