ios - A issue of a variable regarding to refreshing table view -
i have tableview using odrefreshcontroll. , have uislider in view controller (let myviewcontroller) , slider changing variable (let myvariable) of tableview. main issue if change myvariable myviewcontroller slider , refresh tableview, myvariable turns initial value. provide code little bit mess code, please ask not understand code. here code:
@ mytableview.h: #import <uikit/uikit.h> #import <quartzcore/quartzcore.h> #import "odrefreshcontrol.h" @interface mytableview : uitableviewcontroller -(void)gettingvariablefrommyviewcontroller; @end
at mytableview.m
#import "mekanlistesi.h" #import "appdelegate.h" #import "ayarlar.h" @interface mytableview () @property(strong)nsnumber *myvariable; @end @implementation mytableview @synthesize myvariable; - (id)initwithstyle:(uitableviewstyle)style { self = [super initwithstyle:style]; if (self) { // custom initialization } return self; } -(void)gettingvariablefrommyviewcontroller{ nsstring *unsettedvariable = [(appdelegate *)[[uiapplication sharedapplication] delegate] variableuniversal]; if (!unsettedvariable) { unsettedvariable= @"10000000000000000"; } nsnumberformatter * nsnf= [[nsnumberformatter alloc] init]; [nsnf setnumberstyle:nsnumberformatterdecimalstyle]; self.myvariable=[degmesinellerimiz numberfromstring:alinanyaricap]; } - (void)dropviewdidbeginrefreshing:(odrefreshcontrol *)refreshcontrol { double delayinseconds = 1; dispatch_time_t poptime = dispatch_time(dispatch_time_now, delayinseconds * nsec_per_sec); dispatch_after(poptime, dispatch_get_main_queue(), ^(void){ [refreshcontrol endrefreshing]; }); }
at myviewcontroller.h
#import <uikit/uikit.h> @interface myviewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uislider *myslider; - (ibaction)actionmyslider:(id)sender; @property (weak, nonatomic) iboutlet uilabel *myvariabellabel; @end
at myviewcontroller.m
#import "myviewcontroller.h" #import "appdelegate.h" #import "mytableview.h" @interface myviewcontroller() @end @implementation myviewcontroller @synthesize myvariablelabel; @synthesize myslider; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (ibaction)actionmyslider:(id)sender{ myvariablelabel.text = [nsstring stringwithformat:@"%1.1f",myslider.value]; [(appdelegate *)[[uiapplication sharedapplication] delegate] setuniversalvariable:[nsstring stringwithformat:@"%f",myslider.value]]; mytableview *mtv=[[mytableview alloc]init]; [mtv gettingvariablefrommyviewcontroller]; [mtv.tableview reloaddata]; }
(at appdelegate universalvariable setted
@property(nonatomic,retain)nsstring *universalvariable; @synthesize universalvariable;
)
note: coping , pasting code xcode , make changes names of methods, classes , variables due fact native language not english, there can mistakes names of those, please warn me if see 1 of errors.
thank you.
the problem not pull refresh, problem in code somewhere setting wrong value variable. setting new value variable, because in gettingvariablefrommyviewcontroller checking value store in app delegate if don't set anywhere new value in app delegate, gettingvariablefrommyviewcontroller return/set same value @"10000000000000000
Comments
Post a Comment