ios - Pass back data using [popviewcontroller], and reload data -


http://imgur.com/2lajmvd

in picture provided above, shows 3 view controllers.

let's call view controllers a, b, , c in order they're displayed.



view controller a passes parsed json data clicking on table cell. fills "total sales, discounts, etc." strings/labels inside of view controller b using prepareforsegue method.

this data based on start time/end time , default parameter when performing segue gives information 8 10 pm of current day.

parsing string looks this

nsdate *currentdate = [nsdate date];             nsdateformatter *dateformatter = [[nsdateformatter alloc] init];             [dateformatter setdateformat:@"yyyy-mm-dd"];             nsstring *thedate = [dateformatter stringfromdate: currentdate];  nsstring *salesstr = @"http://"; salesstr = [salesstr stringbyappendingstring:host]; salesstr = [salesstr stringbyappendingstring:@":8080/sales.php?password="]; salesstr = [salesstr stringbyappendingstring:pass]; salesstr = [salesstr stringbyappendingstring:@"&db="]; salesstr = [salesstr stringbyappendingstring:db]; salesstr = [salesstr stringbyappendingstring:@"&sdate="]; salesstr = [salesstr stringbyappendingstring:thedate]; salesstr = [salesstr stringbyappendingstring:@"%2008:00:00&edate="]; salesstr = [salesstr stringbyappendingstring:thedate]; salesstr = [salesstr stringbyappendingstring:@"%2022:00:00"]; 

inside of view controller b, can notice button labeled "start time". button initiates push segue view controller c. in new view controller, able select date , time , displayed in uilabel above date picker. button below date picker ibaction , uses

[self.navigationcontroller popviewcontrolleranimated:yes]; 



my question is: how able select date/time in view controller c, press button, , send information located in uilabel view controller b can used update parsed information?

one way think of doing have button segue view controller b, , re-parse information based on date/time selection, cause 'navigation controller stacking' , doesn't seem efficient me.

any suggestions appreciated.

hacker's approach work.

apple's documentation suggests different technique. define simple protocol method view controller c can use communicate view controller b.

then give view controller c delegate property conforms protocol.

in prepareforsegue method, set view controller c's delegate.

then, in view controller c, when user changes date , clicks button, invoke delegate method notify view controller b user changed date value before popping yourself.

i suggest adding cancel button well, user can discard changes. in case, skip calling delegate method before popping.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -