I want to ask the size of the NSMutable Array can be 2000? If not, is it possible to open an array to store 2000 elements. The elements is the user-defined object. Thank you.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer is that an NSMutableArray always starts with a size of zero. If you want it to be so you can do something like this:
you need to prefill the array with NSNull objects e.g.
Edit: some further clarification:
-initWithCapacity:provides a hint to the run time about how big you think the array might be. The run time is under no obligation to actually allocate that amount of memory straight away.will log a count of 0.
-initWithCapacity:does not limit the size of an array:doesn’t cause an error.