Making an array of integers in iOS

后端 未结 7 1978
悲哀的现实
悲哀的现实 2020-12-07 12:17

If you want to make an array of integers, can you use NSInteger? Do you have to use NSNumber? If so, then why?

相关标签:
7条回答
  • 2020-12-07 12:50

    You can use CFArray instead of NSArray. Here is an article explaining how.

    CFMutableArrayRef ar = CFArrayCreateMutable(NULL, 0, NULL);
    for (NSUInteger i = 0; i < 1000; i++)
    {
      CFArrayAppendValue(ar, (void*)i);
    }
    CFRelease(ar); /* Releasing the array */
    

    The same applies for the CoreFoundation version of the other containers too.

    0 讨论(0)
提交回复
热议问题