将Objective-C翻译成Swift?

时间:2015-02-04 03:49:36

标签: objective-c swift

我需要帮助将此转换为快速。有任何想法吗?

NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:pushMessage, @"alert", @"increment", @"badge",  nil];

1 个答案:

答案 0 :(得分:1)

您可以在swift中初始化该字典,如下所示,最后得到一个等效的NSDictionary:

let data : NSDictionary = [  "alert" : pushMessage, "badge" : "increment" ]

有关详细信息,请参阅Apple's section on collection types within the Swift programming language documentation

希望有所帮助!