2016-10-31 3 views
0
var category:UIMutableUserNotificationCategory=UIMutableUserNotificationCategory() 
category.identifier="DEFAULT_GATEGORY" 
let defaultAction:NSArray=[action] 
category.setActions(defaultAction as [AnyObject] as [AnyObject], forContext: UIUserNotificationActionContext.Minimal) 
+0

Welche Art ist 'action'? –

+0

@JefferyThomas UIMutableUserNotificationAction – nene

+0

Es wäre gut, wenn Sie Ihre Situation erklären, was genau Sie tun, was haben Sie versucht, etc. Es hilft anderen Benutzern, Ihnen zu helfen: D –

Antwort

0

action Unter der Annahme, ist vom Typ UIUserNotificationAction:

var category = UIMutableUserNotificationCategory() // NOTE: type not needed. 
category.identifier = "DEFAULT_GATEGORY" 
let defaultAction = [action] // NOTE: Type not needed. 
category.setActions(defaultAction, forContext: UIUserNotificationActionContext.Minimal) 

Wie Sie sehen können, alles, was ich war nicht benötigte entfernen tat (und irreführend) Informationen eingeben. Ich finde es hilfreich, sich auf das automatische Typbestimmungssystem von Swift zu stützen.


mit folgendem Spielplatz Code getestet:

let action = UIMutableUserNotificationAction() 
var category = UIMutableUserNotificationCategory() 
category.identifier = "DEFAULT_GATEGORY" 
let defaultAction = [action] 
category.setActions(defaultAction, forContext: UIUserNotificationActionContext.Minimal) 
Verwandte Themen