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.
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 you find the length of an array in C#? To find the length of an array, use the Array. Length() method.
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.
You can use [XYZ count] to get the length of the array
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With