问题
i am working on a notification project, see this: Swift notification fire from datePicker
The problem is this: i have a variable
item = news.titleNews
(in ViewController.Swift) that is a list of strings like this:
one
two
three
etc..
i am converting this variable to an array like this:
myArray = [item]
and saving to NSUserDefaults like that:
NSUserDefaults.standardUserDefaults().setObject(myArray, forKey:"myArray")
NSUserDefaults.standardUserDefaults().synchronize()
then in settings.swift if i put:
localNotification.alertBody = NSUserDefaults.standardUserDefaults().objectForKey("myArray")
i receive only nil...or if i pass through NSUserdefaults only item string my notification is only one corresponding to first string! i want a notification for each string of my strings list. Thank you in advance for the Help.
来源:https://stackoverflow.com/questions/34257339/swift-save-an-array-of-strings-to-nsuserdefaults-and-reuse-for-notification-aler