Maximum amount of objects in NSArray

前端 未结 6 576
耶瑟儿~
耶瑟儿~ 2020-12-11 04:19

What is the largest amount of objects I can put in my NSArray?

6条回答
  •  渐次进展
    2020-12-11 05:07

    NSArray is a container of pointers to other objects. Its maximum capacity is defined by NSUInteger (on the latest versions of the available OSs):

    When building 32-bit applications, NSUInteger is a 32-bit unsigned integer. A 64-bit application treats NSUInteger as a 64-bit unsigned integer

    Therefore, whatever the size of NSUInteger is on a given device is the maximum number of object pointers it can contain. However, as Eimantas alluded to in his answer, this isn't the same as "how many objects can it hold" because this depends on available memory. You may not have enough RAM available at a given moment to allocate an array with six billion slots for example ...

提交回复
热议问题