0

Few days back this question was about changing the label text from an other class. I changed a few things around:

I now have a function setLabelText:

- (void)setLabelText:(NSString*)text{
    //myLabel.text = text;
    [myLabel performSelectorOnMainThread : @ selector(setText : ) withObject:text waitUntilDone:YES];
    NSLog(@"class:%@, label:%@", self, myLabel);
}

Both self and label are filled, but the display is not showing the correct text..

I'm calling this function from an other class, if I change my label text from a button on the viewcontroller it changes correctly.

EDIT:

I have the label changing now, every time when the class is done with it's functions the label edits the text. Although.. this is always the last set value, I need it to change every time it gets into a for loop, how can I get this to work? Seems it doesn't update the viewController while the app is doing it's for loop

tshepang
  • 12,111
  • 21
  • 91
  • 136
Lofens
  • 161
  • 1
  • 9
  • are u creating viewController obj in your custom class? – Shamsudheen TK Oct 30 '12 at 14:44
  • see my anwr. it will help you http://stackoverflow.com/questions/12911115/passing-nsmutablearray-from-modal-view-controller-to-parent-view/12911361#12911361 – Shamsudheen TK Oct 30 '12 at 14:46
  • Yes I created the viewController obj, it goes through the correct functions as well. Your answer works with segues, I'm always on the same view, not switching views. I'm also not reinitializing the object, so that's not the case I believe. – Lofens Oct 30 '12 at 14:49
  • if you create new viewController obj, the viewController will nil. So please avoid allocating viewController obj any way. – Shamsudheen TK Oct 30 '12 at 14:54
  • I init/alloc the obj in the delegate, creating the obj in the custom class setting it to the obj created in the delegate. so it shouldn't be a new obj right? It's the same I use everytime and the rest goes fine. – Lofens Oct 30 '12 at 14:59
  • please share your code.. you can use http://pastebin.com/ to share ur code – Shamsudheen TK Oct 30 '12 at 15:02
  • I edited my question giving you the code you need, I'm not really allowed to share the code :< If you need more, ask. – Lofens Oct 30 '12 at 15:16
  • where you decalred/alloced CustomClass ? inside MyViewController ? – Shamsudheen TK Oct 30 '12 at 15:24
  • then share the CustomClassn allocation code – Shamsudheen TK Oct 30 '12 at 15:24
  • Where and how did you create myLabel? Using IB? If so, did you connect it properly to the related IBOutlet? – Hermann Klecker Oct 30 '12 at 15:27
  • It's in my appDelegate as said, it initializes as soon as the app starts. 'customClass = [[CustomClass alloc] init];' – Lofens Oct 30 '12 at 15:28
  • is viewController is nil ? or only viewController.myLabel? – Shamsudheen TK Oct 30 '12 at 15:31
  • is viewController contains any value or reference ? – Shamsudheen TK Oct 30 '12 at 15:31
  • When I'm logging the customclass itself it shows me no NULL, so the customclass itself shouldn't be NULL, the IBoutlet is connected as should, I can change the label text within the viewcontroller itself. The only thing that is on the viewController is this label and a button the launch an other class – Lofens Oct 30 '12 at 15:33
  • My label isn't NULL anymore, when I enter the viewController from the CustomClass the label is set and the text of the label changed, however.. the new text won't appear in the simulator – Lofens Oct 31 '12 at 08:16
  • `I init/alloc the obj in the delegate, creating the obj in the custom class setting it to the obj created in the delegate. so it shouldn't be a new obj right?` it looks exactly like setting the new value, can you describe it with more details ? – A-Live Nov 02 '12 at 11:55
  • @A-live I'm not using these methods anymore, as edited in my question it does change the text but when the class is done, not before, and gets it's last set value – Lofens Nov 02 '12 at 13:46

0 Answers0