override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
let textViews = [answersTextView[0],answersTextView[1], answersTextView[2], answersTextView[3], answersTextView[4], questionTextView]
for textView in textViews {
var range = textView!.selectedTextRange
var selectedText = textView!.text(in: range!)
if range == textViews[0]!.selectedTextRange {
}
if range != nil {
let alert = UIAlertController(title: selectedText, message: "", preferredStyle: .actionSheet)
let action = UIAlertAction(title: "KELİME DEFTERİNE EKLE", style: .default) { action in
self.newWords.append(words(word: selectedText!))
let propertyList = PropertyListEncoder()
do { let encoded = try? propertyList.encode(self.newWords)
try? encoded?.write(to: wordssarchiveURL)
}
print(selectedText!)
print(self.newWords)
}
alert.addAction(action)
present(alert, animated: true,completion: nil)
}
}
return true
}