Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Length of an `int` array in Objective C

I am passing an Integer array to a function. Next I want to traverse through the array. In C and C++ this worked by simply using arrayname.length which gave the number of elements in array. What is the way to find that in Objective-C?

[NSArrayObject length] works for NSArray type but I want it for int[]. Not even [XYZ count] works (an already suggested answer) so I'm looking for another way here.

like image 472
Darpan Avatar asked Oct 07 '09 07:10

Darpan


People also ask

How do you find the length of an int array?

To determine the size of your array in bytes, you can use the sizeof operator: int a[17]; size_t n = sizeof(a); On my computer, ints are 4 bytes long, so n is 68. To determine the number of elements in the array, we can divide the total size of the array by the size of the array element.

How do I get the length of an array in CS?

How do you find the length of an array in C#? To find the length of an array, use the Array. Length() method.

What is array length ()?

length is a property of arrays in JavaScript that returns or sets the number of elements in a given array. The length property of an array can be returned like so. let desserts = ["Cake", "Pie", "Brownies"]; console. log(desserts.


1 Answers

You can use [XYZ count] to get the length of the array

like image 104
user2070420 Avatar answered Oct 04 '22 01:10

user2070420