database - Swift Code ending during variable set -


i have following code, , reason when gets line

let num = data[pagesleft]

the code stops, , cant figure out why. it's not fatal error or anything, ends code execution complete. ideas why doing that?

i have data variable @ top level access , when print it, looks right me.

func passdata (passdata : [scheduleobject]) {     data = passdata     print(passdata.count)     print(data)     updatetemplate() }  func updatetemplate() {     pagesleft = data.count     print(pagesleft)     let num = data[pagesleft]      let weekobj = num.weekobj     weekobj.fetchinbackground()      customername.text! = num.customername     address.text! = num.customeraddress     phonenumber.text! = num.customerphone     openingweek.text! = globalfunctions().stringfromdateshortstyle(weekobj.weekstart) + " " + globalfunctions().stringfromdateshortstyle(weekobj.weekend)     if num.confirmeddate != nil {         openingdate.text! = globalfunctions().stringfromdateshortstyle(num.confirmeddate!)     } else {         openingdate.text! = "not confirmed"     }     if num.confirmedwith != nil {         confirmedwith.text! = num.confirmedwith!     } else {         confirmedwith.text! = "not confirmed"     }     typeofwintercover.text! = num.covertype     itemlocation.text! = num.locessentials     if (num.bringchem) {         bringchemicals.text! = "yes"     } else {         bringchemicals.text! = "no"     }     if (num.taketrash) {         taketrash.text = "yes"     } else {         taketrash.text = "no"     }     notes.text = num.notes!     accountnumber.text! = num.accountnumber!       if (firsrun) {         createpdffromview(theview, savetodocumentswithfilename: "poc")         firsrun = false     }  } 

with let num = data[pagesleft] pagesleft = data.count, you're automatically out of index range of data.

the last index of array x x.count - 1.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -