ios - UIViewPageContorller calling other UIViewPage function (swift 3)? -


i newbie in ios development. trying apps call or execute function on uiviewpage uiviewpagecontroller. can 1 advise on this?

  1. this page load in uipageviewcontroller:
 public func pageviewcontroller(_ pageviewcontroller: uipageviewcontroller, viewcontrollerafter viewcontroller:  uiviewcontroller) -> uiviewcontroller?{      //refresh json file     loadjsonrecords()     guard let viewcontrollerindex = vcarr.index(of: viewcontroller) else {         return nil     }     viewcontroller[     let nextindex = viewcontrollerindex + 1     guard nextindex < vcarr.count else {         return vcarr.first     }     guard vcarr.count > nextindex else {         return nil     }   //here start code call uiviewpage's function      return vcarr[nextindex]   } 
  1. this uipageview function wish call uipageviewcontroller:
 func retrievefromjsonfile() {     // url of json in document directory     guard let documentsdirectoryurl = filemanager.default.urls(for: >.documentdirectory, in:     .userdomainmask).first else { return }     let fileurl = documentsdirectoryurl.appendingpathcomponent("xxxx.json")      // create read-only stream     guard let stream = inputstream(url: fileurl) else { return }     stream.open()     defer {         stream.close()     }      // read data .json file , transform data array     {         guard let parsedarray = try jsonserialization.jsonobject(with: stream, options: []) as?    [[string:any]] else { return }         assignvalue(passin: parsedarray)     } catch {         print(error)     } } 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -