本文介绍了UITextInputMode.activeInputModes()在Swift 2中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Swift 2中获得UITextInputMode,但是UITextInputMode.activeInputModes()崩溃.

I want to get UITextInputMode in Swift 2 but UITextInputMode.activeInputModes() crashes.

    let x = UITextInputMode.activeInputModes() // crash here

    for t in x {
        print(t)
    }

推荐答案

这是Xcode 7中的错误,如所述 HERE .上面写着:

It is a bug in Xcode 7 as mentioned HERE. Which says:

在Xcode 7 GM之前,返回UITextInputMode.activeInputModes() UITextInputMode实例的数组.但是,在Xcode 7 GM中, 头文件和文档中的方法签名指出 返回一个字符串数组,这是不正确的.结果,代码 正确使用activeInputModes的文件将不再编译,并且 尝试在操场上使用activeInputModes会抛出一个

Prior to the Xcode 7 GM, UITextInputMode.activeInputModes() returned an array of UITextInputMode instances. However, in the Xcode 7 GM, the method signature in the header file and documentation states that it returns an array of Strings, which is incorrect. As a result, code that uses activeInputModes correctly no longer compiles, and attempting to use activeInputModes in a Playground throws an exception.

这篇关于UITextInputMode.activeInputModes()在Swift 2中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 17:12