ios - How to connect viewcontroller to NSObject class file? -


i want connect , pass action viewcontroller nsobject class file. in viewcontroller, there uiswitch button , if switch want work in nsobject class file.

when switch on viewcontroller (uiview) action have work in nsobject class file.

i'm coding objective-c.

here viewcontroller.m , did in viewcontroller file. not connected nsobject class file.

- (void)viewdidload{  [super viewdidload];  //uiswitch work @ viewdidload  [self.myswitch addtarget:self                   action:@selector(statechanged:) forcontrolevents:uicontroleventvaluechanged]; }   - (void)statechanged:(uiswitch *)switchstate{  nslog(@"current calendar: %@", [[nscalendar currentcalendar] calendaridentifier]); //get date today nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdatestyle:nsdateformattermediumstyle]; [formatter setcalendar:[nscalendar currentcalendar]]; nsstring *datetoday = [formatter stringfromdate:[nsdate date]]; nslog(@"today date is: %@", [nsdate date]); self.mylabel.text=datetoday;  if ([switchstate ison]) {      //[formatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us@calendar=japanese"]];     [formatter setcalendar:[[nscalendar alloc] initwithcalendaridentifier:nscalendaridentifierjapanese]];      [formatter setdateformat:@"yyyy-mm-dd hh:mm:ss"];     [formatter settimezone:[nstimezone timezoneforsecondsfromgmt:0]];      nsstring *datetoday = [formatter stringfromdate:[nsdate date]];      uilabel *dtdate = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 320.0f, 20.0f)];     [dtdate settext:datetoday];      self.mylabel.text =datetoday;     nsstring *locale = [[nslocale currentlocale] localeidentifier];     nslog(@"current date is: %@", datetoday);     nslog(@"current locale: %@", locale);  } else {      //[formatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us"]];     [formatter setcalendar:[nscalendar autoupdatingcurrentcalendar]];     [formatter setdateformat:@"yyyy-mm-dd hh:mm:ss"];     [formatter settimezone:[nstimezone timezoneforsecondsfromgmt:0]];     nsstring *datetoday = [formatter stringfromdate:[nsdate date]];      uilabel *mylabel = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 320.0f, 20.0f)];     [mylabel settext:datetoday];      self.mylabel.text =datetoday;     //        nsdateformatter *formatter = [[nsdateformatter alloc] init];     //        [formatter setdatestyle:nsdateformattermediumstyle];     nsstring *locale = [[nslocale currentlocale] localeidentifier];     nslog(@"current locale: %@", locale);     nslog(@"%@", [formatter stringfromdate: [nsdate date]]);    } } 

if need action use class methods else create global variable or notification observer in nsobject extended class when call switch.

- (void)callback:(id)sender  {      [myobject switchstate:sender.state];  } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -