xcode - IOS 7 - Update an UILabel with value computed in background using delegation -


i having problem trying update uilabel.text using value calculate in background using delegation (which seems slow).

@interface btaviewcontroller : uiviewcontroller <exchangefetchermanagerdelegate>      @property (weak, nonatomic) iboutlet uilabel *bidpricelabel;     @property (strong, nonatomic) fetchermanager *fetchermanager;  @end 

my btaviewcontroller.m

- (void)viewdidload {     [super viewdidload];      self.fetchermanager = [[fetchermanager alloc]init];     double calculatevalue = [self.fetchermanager fetchpricesfor];       self.bidpricelabel.contentmode = uiviewcontentmoderedraw;     [self.bidpricelabel setneedsdisplay];     self.bidpricelabel.text = [[nsstring alloc] initwithformat:@"%f", calculatevalue];  }];  

the label has been correctly initialised in method not shown here , shows correct default value @ startup. once execute code, label value 0.00000000, because calculatevalue has not been calculate yet.

how can wait value calculated , display has text of label ?

i can't post images because don't have enough reputation...

thanks

are sure value calculated not purely 0 or null?

what add delegate callback function in btaviewcontroller.m fetchmanager

something this:

btaviewcontroller.h //add delegate callback function under @interface -(void)valuereturned:(float)somevalue;    btaviewcontroller.m  -(void)valuereturned:(float)somevalue{ //updates value when delegate returns value     self.bidpricelabel.text = [[nsstring alloc] initwithformat:@"%f", calculatevalue]; }  - (void)viewdidload {     [super viewdidload];      self.fetchermanager = [[fetchermanager alloc]init];     self.fetchmanager.delegate = (id)self;     [self.fetchmanager getpricesfor];     // double calculatevalue = [self.fetchermanager fetchpricesfor];       self.bidpricelabel.contentmode = uiviewcontentmoderedraw;     [self.bidpricelabel setneedsdisplay];     [self.view addsubview:self.bidpricelabel]; }];  

in fetchmanager.h , .m

fetchermanager.h  @property (retain,nonatomic)id<exchangefetchermanagerdeelgate>delegate; -(void)getpricesfor;    fetchermanager.m @synthesize delegate;  -(void)getpricesfor{     float price;     //calculate price     [self.delegate valuereturned:price]; } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -