Hey I have problem placing variables. How can I use variables those that I use lets say in function "A" in another function "B". In another word use variables from Function "A" in function "B"
I have function("A") to set notification text:
let sentence = textField.text! + " Some beautiful text!"
let firstWord = sentence.characters.split(" ").first.map(String.init)
LocalNotificationHelper.sharedInstance().scheduleNotificationWithKey("someText", title: "see options(left)", message: sentence, date: deadlinePicker.date, userInfo: userInfo)
Now I gotta call the firstWord inside another function("B") in that variable here:
let predicate = CNContact.predicateForContactsMatchingName(firstWord)
I tried to add those first variables sentence and firstWord in ViewDidLoad and outside of class but for nothing. I keep getting error "found nil while unwrapping"
I call the function where is variable predicate when user tap notification action button like this.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "functionWhereIsPredicateVariable:", name: IDENTIFICATOR, object: nil)
Do I have to store the firstWord into NSUserDefaults or do I have to do it in another way??
Aucun commentaire:
Enregistrer un commentaire