核心数据布尔属性NSNumber不记得它的布尔值 [英] Core Data Boolean property NSNumber doesn't remember it's boolean

查看:98
本文介绍了核心数据布尔属性NSNumber不记得它的布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有如下属性的模型:

I have a model with a property that looks like this:

当我设置其值时,例如:

When I set its value, for example:

model.isResolved = @YES;

保存在模型中的NSNumberforgets是一个布尔值:

The NSNumber that's kept inside the model "forgets" that it's a boolean:

NSLog(@"%@", strcmp([self.isResolved objCType], @encode(BOOL)) == 0 ? @"equal" : @"different");

打印不同。

推荐答案


这是什么?

What is up with that?

文档


请注意,数字对象不一定保存它们创建的类型。

Note that number objects do not necessarily preserve the type they are created with.

这是Cocoa中另一个不一致的优化。

That's another inconsistency-for-optimization in Cocoa.

这篇关于核心数据布尔属性NSNumber不记得它的布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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