ios - how to find a string property that corresponds to a gesture.view in Swift? -
i have json file containing array of dictionaries:
"question":"question text", "answers":["yes", "no"], "answertracker":["1a", "1b"]
i have created question class & answer button view class display questions & answers in view.
in view controller have far displayed questions, created answer buttons, , finally, added tapgesturerecogniser each button.
func answertapped(gesture:uitapgesturerecognizer) { // access button tapped let selectionbuttonthatwastapped:selectionbuttonview? = gesture.view as? selectionbuttonview if let actualbutton = selectionbuttonthatwastapped { // find out index button has been tapped let selectiontappedindex:int? = find(self.selectionbuttonarray, actualbutton) **// find answer tracker button has been tapped?** // append tracker selected button user generated code if let actualanswertracker:string = self.answertracker string! { self.usergeneratedcode.append(actualanswertracker) }
in tapgesturerecognizer method above need find corresponding answertracker (string) answer button tapped (uiview) can't find way? answertracker string corresponding tapped answer appended string array property called usergeneratedcode.
any suggestions?
you not need add tapgesturerecogniser
button, can add target , selector button anyway. if want know button pressed, can use tag property on uibutton
check against.
Comments
Post a Comment