在Swift中使用isKindOf [英] Using isKindOf in Swift

查看:1406
本文介绍了在Swift中使用isKindOf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Xcode 8.0 beta测试我的应用程序,但在将我的代码2.2转换为3.0之后,出现了许多未解决的错误。在演示下方,Xcode8.0出现错误消息

I use Xcode 8.0 beta to test my app, but after it convert my code 2.2 to 3.0, came out many unsolved bugs. Below the demo, Xcode8.0 appear the error message


1。 if条件后的预期{...



    if annotation.isKindof: (MKUserLocation) {
        return nil
    } 

第二个错误是地图工具包...我使用iskind(of:MKUserLocation)仍然没有工作,它会出现另一个错误信息

Second error is the map kit...I use iskind(of: MKUserLocation) still not work out, it will appear another error message


2.Braced of statement是一个未使用的闭包



    if annotation.isKindof: (MKUserLocation) {
        return nil
    }




第3。缺少参数标签'of:'in call



    if annotation.isKind(of: MKUserLocation) {
        return nil
    }


推荐答案

替换 Swift3 是:

if annotation is MKUserLocation {
    return nil
}

这篇关于在Swift中使用isKindOf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆