在目标C数组长度 [英] Length of an Array in Objective C

查看:136
本文介绍了在目标C数组长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有在任何提出的问题找到答案。
我传递一个整数数组到function.Now我想通过array.But遍历的东西在C,C ++曾使用arrayname.length简单这给数组元素的数量。什么是查找的方式?
[NSArrayObject长度]适用于NSArray的类型,但我想它对于int []。
甚至没有[XYZ数]工程....所以想另辟蹊径,发现了这一点。

I haven't found answer in any of the questions asked. I am passing an Integer Array to a function.Now I want to traverse through the array.But as things worked in C,C++ by simple using arrayname.length which gave the number of elements in array. What is the way to find that? [NSArrayObject length] works for NSArray type but I want it for int[] . not even [XYZ count] works....so want another way to find that out.

推荐答案

有没有具体到Objective-C的任何与int数组。因为如果你是用C你会使用相同的技术。

There isn't anything specific to Objective-C with an array of ints. You would use the same technique as if you were using C.

sz = (sizeof foo) / (sizeof foo[0]);

这篇关于在目标C数组长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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