UIPickerView 的 NumberOfRowsInComponent 正确注册我从核心数据返回的 int 16 值的问题
我有一个 Book 数据实体,它有一个名为 numBooks 的 int 16 类型值作为属性。由于一切设置的方式,我实际上是在 titleForRow 中获取我需要的数字,并将该值保存到 NSNumber 类型的全局变量中。
在 titleForRow 中,我以这种方式设置全局变量:
global = book.numBooks;
如果在设置全局变量后我 NSLog,它将向控制台返回正确的数值(50,具体取决于)。但是,如果我只是将 book.numBooks 打印到控制台,则该值完全不同,100499556。
现在,问题是,当我将全局变量带回到 numberOfRowsInComponent 时,用作给定组件的行数,这个数字似乎无穷无尽。我可以滚动和滚动,但它显然无法正常工作。
uiPickerView numberOfRowsInComponent 只需要一个 int 吗?它基本上认为我传递的值是 100499556 吗?
请帮忙,谢谢!
I have a Book data entity that has as an attribute an int 16 type value called numBooks. Due to the way everything is setup, I am actually grabbing the number I need inside titleForRow, and saving the value to a global variable of type NSNumber.
In titleForRow, I am setting the global in this way:
global = book.numBooks;
If I NSLog my global variable after it is set thus, it returns to the consol the proper number value (50 depending). But, if I were to just print book.numBooks to the console, the value is quite different, 100499556.
Now, the problem is that when I take my global variable back to numberOfRowsInComponent, to use as the count of rows for a given component, there is seemingly no end to the number. I can scroll and scroll and it obviously isnt working right.
Does the uiPickerView numberOfRowsInComponent only want an int? Is it basically thinking that the value I am passing it is that 100499556?
Please help, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下
您可能会看到 NSNumber* book.numBooks 的指针值。
Try
You are probably seeing a pointer value for the NSNumber* book.numBooks.