0

I am trying to set a label text with the text i selected from my tableview. Here are my codes

- (void)viewDidLoad
{
//  Location *l = [[Location alloc]init];
// [l view];

[super viewDidLoad];
// Do any additional setup after loading the view.
[pLabel setText:[self selectedText]];

NSLog(@"%@1", [self selectedText]);

}

-(id) initWithTextSelected:(NSString *) text {
self.selectedText = text;
[pLabel setText:selectedText];

NSLog(@"%@2", [self selectedText]);
return self;
}

I can't seem to set my label. In addition, NSLog 1 prints out null while NSLog 2 displayed my selected value.

Hexark
  • 413
  • 6
  • 22

2 Answers2

0

i think the selectedText at the viewDidLoad is null because it is not retained and instead of using setText: use pLabel.text = selectedText;

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
0

At NSLog 2 ou are setting self.selected text.

but in viewDidLoad there is any code that setting the selectedText. Be sure that you are setting your "selectedText".

mhunturk
  • 296
  • 2
  • 12