You don't seem to be calling [self gettingUser];
or [self gettingTime];
anywhere. You should call these methods after setting up your text fields and as Michael said, you use self.name
rather than _name
etc when accessing your properties
- (void)viewDidLoad
{
[super viewDidLoad];
self.username = [[UILabel alloc] initWithFrame:CGRectMake(162, 106, 150, 72)];
[self.view addSubview: self.username];
self.username.numberOfLines = 4;
self.username.textColor = [UIColor blackColor];
[self gettingUser];
self.date = [[UILabel alloc] initWithFrame:CGRectMake(160, 261, 1488, 44)];
[self.view addSubview: self.date];
self.date.numberOfLines = 4;
self.date.textColor = [UIColor blackColor];
[self gettingTime];
}
-(void) gettingUser
{
self.name=[[UIDevice currentDevice] name];
self.username.text = [NSString stringWithFormat:@"Usuari: %@", self.name];
}
-(void) gettingTime
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
self.currentTime = [dateFormatter stringFromDate:[NSDate date]];
self.date.text = [NSString stringWithFormat:@"Hora: %@", self.currentTime];
}