对象类型“id”的属性

发布于 2024-12-15 04:11:34 字数 309 浏览 3 评论 0原文

我敢打赌这是一个非常基本的问题,但我不明白!

我加载一些 REST 数据并将其放入 NSMutableArray 中的对象中。

  1. 加载 REST-Data
  2. 将 Rest-Data 解析为对象
  3. 将对象添加到 NSMutable 数组

现在我需要访问存储在可变数组中的对象的一些属性,并且我收到 Xcode 错误,指出在中没有给定名称的属性“id”类型的对象。

有人可以给我一个快速提示吗?我想我可以直接使用 NSMutable 数组中的对象及其属性。

感谢您的帮助!

I would bet this is a very basic question, but i don't get it!

I load some REST Data and put it in Objects in a NSMutableArray.

  1. Load REST-Data
  2. Parsing the Rest-Data to Objects
  3. Add the Objects to a NSMutable Array

now i need to access some properties of the objects stored in the mutable array and i get Xcode errors, stating that there is no property with the given name in object of type "id".

Could somebody give me a quick hint? I thought i could use the Objects and their properties within the NSMutable Array directly.

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

过期以后 2024-12-22 04:11:34

您可能需要转换可变数组中的对象,而不是使用点表示法。如在

[anArray objectAtIndex:i].yourProperty; // will give you an error
[(YourClass*)[anArray objectAtIndex:i] yourProperty]; // should work

You probably need to cast the objects in your mutable array, and not use the dot notation. As in

[anArray objectAtIndex:i].yourProperty; // will give you an error
[(YourClass*)[anArray objectAtIndex:i] yourProperty]; // should work
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文