Reputation: 902
Im trying this code in one Controller.h
@interface ColorPickerViewController : UIViewController {
IBOutlet UILabel *Labelniz;
}
@property (nonatomic, retain) UILabel* Labelniz;
This code in Controller.m
@implementation ColorPickerViewController
@synthesize Labelniz=_Labelniz;
But i using something like ColorPickerViewController.Labelniz
gives an error.
Thank you in advance.
Upvotes: 0
Views: 484
Reputation: 2261
Create a property in the UIViewController that you want to access the label from, just like you did with the label in but for ColorPickerViewController. Then when you push/present the new view, set it to self.
ColorPickerViewController *colorPickerViewController;
@propery (nonatomic, retain) ColorPickerViewController *colorPickerViewController;
and of course:
@syntesize colorPickerViewController
set it to self right before the view is presented:
viewThatYouArePresenting.colorPickerViewController = self.
[self.navigationController pushViewController:youViewController animated:YES]//Or whichever your using, this is just an example
then you can set it from the view like you were doing:
colorPickerViewController.Labelniz = @"xxxxx";
doing this:
ColorPickerViewController *controller = [[ColorPickerViewController alloc] init];
instantiates another instance of that controller so it is essentially changing the label of the newly instatiated ColorPickerViewController.What you want is to change the label in the ColorPickerViewController that is already instantiated.
Upvotes: 1
Reputation: 5812
I hope you are doing it this way
ColorPickerViewController *controller = [[ColorPickerViewController alloc] init];
controller.Labelniz = .......
ColorPickerViewController is the class, and controller is the object. you can access properties of a particular object (in this case the Labelniz property of the controller object).
Upvotes: 0