UIPickerView 的 NumberOfRowsInComponent 正确注册我从核心数据返回的 int 16 值的问题

发布于 2024-10-01 19:07:13 字数 503 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此刻的回忆 2024-10-08 19:07:14

尝试一下

[book.numBooks intValue];

您可能会看到 NSNumber* book.numBooks 的指针值。

Try

[book.numBooks intValue];

You are probably seeing a pointer value for the NSNumber* book.numBooks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文