override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
//i am trying to send the selected text to another viewController with alert and action
var range = questionTextView.selectedTextRange
let selectedText = questionTextView.text(in: range!)
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)
range = nil
}
return true
}