swift - Accessing information from another viewController -
i new swift , trying repopulate pickerview using array of names class. have class notes creates notes , each note has name/title, trying access names/title , put them in pickerview, can me.
import uikit var allnotes: [note] = [] var currentnoteindex: int = -1 var notetable: uitableview? let kallnotes:string = "notes" class note: nsobject { var date:string var note:string var name:string override init() { date = nsdate().description name = "" note = "" } func dictionary() -> nsdictionary { return ["note": note, "date": date, "name": name] }
i have 2 different pickerview , 1 works it's 1 names doesn't work.
override func viewdidload() { super.viewdidload() filenamepicker.datasource = self filenamepicker.delegate = self gradepicker.datasource = self gradepicker.delegate = self } func pickerview(_ pickerview: uipickerview, numberofrowsincomponent component: int) -> int { if pickerview == gradepicker { return grades.count } else { return allnotes.count } } func pickerview(_ pickerview: uipickerview, titleforrow row: int, forcomponent component: int) -> string? { if pickerview == gradepicker { return grades[row] } else { //this problem is, don't know how fix it. let namefiles = allnotes[currentnoteindex].name return namefiles[row] } } func numberofcomponents(in pickerview: uipickerview) -> int { return 1 }
namefiles
accessing name note.
namefiles[row]
doesn't work because namefiles
not array.
if want return string, return namefiles
. check first make sure namefiles
has value, though!
Comments
Post a Comment