问题描述
我已经无缝使用对象箱3年了。我通过添加一个额外的参数“ public”(一个布尔值)来修改了我的对象之一。当我将对象存储在数据库中时,该值为true。当我从数据库中获取对象时,它是错误的
private fun storeChannelsInDb(channels: List<Models.Channel>) {
channels.forEach { channel ->
val channelMapped = ChannelMapper.toObjectBoxModel(channel)
channelBox.Box.put(channelMapped)
if(channelMapped.channel_id == 7 ){
println("********* storing "+ channelMapped.public)
}
}
}
override fun getChannels(): List<Channel> {
for (channel in channelBox.Box.all){
if(channel.channel_id == 7){
println("********* fetching "+ channel.public)
}
}
return channelBox.Box.all
}
我没有为此参数提供默认值,因为它总是从api返回。我在启动应用程序时获取了这些对象,并在添加它们之前清空了它们。
我尝试添加延迟等,但始终返回false。即使当我提供默认值true时,它也会返回false。任何建议将不胜感激
解决方法
问题在于“公开”是受保护的单词。由于@user:551269
的评论,更改名称解决了该问题。