ios - XCode 版本 6.1 (6A1052d) 更新导致错误 : 'dictionaryWithCapacity' has been explicitly marked unavailable here (Foundation. NSMutableDictionary)

标签 ios xcode cocoa-touch swift nsmutabledictionary

XCode 自动更新,重启后我发现我有很多错误。

这是导致相关错误的代码:

    let navBarTextAttributes = NSMutableDictionary.dictionaryWithCapacity(1)
    navBarTextAttributes.setObject(UIColor.whiteColor(), forKey: NSForegroundColorAttributeName)
    navigationController?.navigationBar.titleTextAttributes = navBarTextAttributes
}

我不确定如何解决这个问题。

谁能给我一些见解?

感谢您的宝贵时间。

最佳答案

Objective-C 类(工厂)方法现在作为自定义初始化程序导入到 Swift 中:

let navBarTextAttributes = NSMutableDictionary(capacity: 1)

关于ios - XCode 版本 6.1 (6A1052d) 更新导致错误 : 'dictionaryWithCapacity' has been explicitly marked unavailable here (Foundation. NSMutableDictionary),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27189674/

相关文章:

ios - CocoaPods 不链接库

ios - 如何使用 NSMutableAttributedString 在我的 UITextView 中加粗一些单词?

ios - iPhone 6 模拟器中的 LaunchScreen 与实体 iPhone 6 不同

ios - 按数量对 HKSampleQuery 项目进行排序

objective-c - 哪种数据存储类型是存储从服务器接收的数据的最佳方式?

objective-c - 如何从 ScrollView 中删除 subview ?

iphone - 用于 XCode 调试的监 window 口

ios - 自动使 View Controller 启动 Segue 转换

objective-c - 何时使用静态字符串与 #define

ios - UIImagePickerController 未计算的内存已保存