最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]Swift中设置布尔变量为YES出错:Cannot assign a value of type ObjCBool to a value of type Bool

Swift crifan 4751浏览 0评论

[背景]

折腾:
[未解决]自定义swift中UITabBarController的高度
期间,想要用swift去设置一个bool变量为true。
都看到对应的定义里面说了,默认是YES:

obj definition of autoresizesSubviews

然后此处去设置值为YES:

        recordTabBarView.view.autoresizesSubviews = YES
竟然出错:
MySchoolCoinViewController.swift:120:53: Cannot assign a value of type ‘ObjCBool’ to a value of type ‘Bool’
 Cannot assign a value of type ObjCBool to a value of type Bool
[解决过程]
1.搜:
swift Cannot assign a value of type ObjCBool to a value of type Bool
参考一堆帖子。
没看懂。
2.后来知道了:
[总结]
swift中的布尔型变量的值是:
true和false
ObjC的是:
TRUE和FALSE
所以改为:
recordTabBarView.view.autoresizesSubviews = true
即可。

转载请注明:在路上 » [已解决]Swift中设置布尔变量为YES出错:Cannot assign a value of type ObjCBool to a value of type Bool

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. ObjCBool.boolValue
    123asaasd7年前 (2016-11-25)回复
89 queries in 0.167 seconds, using 22.09MB memory