ios - Swift 相当于 arrayWIthObjects?

标签 ios objective-c swift nsarray

这是在 Objective-C 中:

NSArray *arr = [NSArray arrayWithObjects:kLMEnglish,nil];

谁能告诉我这行代码的 swift 等价物。

最佳答案

这个呢?

let arr = [kLMEnglish]

在 ObjC 中你也可以这样写:

NSArray *arr = @[kLMEnglish];

关于ios - Swift 相当于 arrayWIthObjects?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30662948/

相关文章:

ios - 如何编写一个单元测试来检查我的属性是否在 iOS 上的 dealloc 中释放?

ios - 如何在 iPhone 的联系人列表中只显示电话号码?

ios - iOS 中 ScrollView 中的可扩展 UIView

ios - 从字符串格式化日期?

ios - 阅读或转换 word .doc 文件 iOS

json - swift 3.0 : tableview cannot show data which received as JSON through web api

ios - UIView 动画无法正常工作?

ios - UIWebView 在 iOS 中加载时显示白屏

Swift: fatal error :从 TableView 中删除项目时数组索引超出范围

swift - 我想回到 TabBarController 中的上一个 viewController