I have two ViewControllers.
FirstViewController has UILabels and UIImageViews. Also generated a Singleton from its class. SecondViewController has a call of that Singleton and should GET values of UILabels and UIImageViews from FirstViewController.
NSString works, UILabel do not.
For example, access a NSString in SecondviewController with "sharedFirstViewController.nsstringvarname" I can GET and SET the value. This works fine!
Trying the same with an UILabel like this: "sharedFirstViewController.uilabelvar.text" I doens´t can SET or GET the value of this UILable. This works NOT!
Is there any special thing with UI-Objects? Would be great if someone can help me with that. Thanks!
EDIT:
in FirstViewController.h
+ (id)sharedFirstViewController;
@property (copy, nonatomic) NSString *path;
@property (strong, nonatomic) IBOutlet UIImageView *pic;
in FirstViewController.m
@synthesize path= _path;
@synthesize pic = _pic;
- (id)init {
if (self = [super init]) {
_pic = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
}
return self;
}
+ (id) sharedFirstViewController {
static sharedFirstViewController * sharedFirstViewController = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedFirstViewController = [[self alloc] init];
});
return sharedFirstViewController;
}
in SecondViewController.m
#import "FirstViewController.h"
- (void)viewDidLoad
{
FirstViewController * sharedFirstViewController = [FirstViewController sharedFirstViewController];
NSLog(@"this is NSString from FVC: %@" sharedFirstViewController.path); //works
UIImage * picture = [UIImage imageWithContentsOfFile:sharedFirstViewController.path];
sharedFirstViewController.pic.image = picture; // does´t work
}