NSNull is a class used to represent an undefined, invalid, or nonexistent object. Therefore, you can put an array at a specific size using instances of this class.
NSUInteger sizeOfArray = 10; NSMutableArray *someArray = [NSMutableArray array]; for (NSUInteger i = 0; i < sizeOfArray; i++) { [someArray addObject:[NSNull null]]; }
Also, you cannot use the syntax someArray[i] = xyz; if the value at position i does not exist, as this will lead to an error outside the bounds.
source share