how to add nil to nsmutablearray?

后端 未结 9 1322
-上瘾入骨i
-上瘾入骨i 2020-12-13 12:22
NSArray *array = [[NSArray alloc] initWithObjects:@\"ΕΛΤΑ\",
                      @\"ΕΛΤΑ COURIER\", @\"ACS\", @\"ACS ΕΞΩΤΕΡΙΚΟ\", 
                      @\"DHL\",          


        
9条回答
  •  难免孤独
    2020-12-13 12:49

    You need to add NSNull class and the best way to do it is like this:

    NSArray *array = @[ @"string", @42, [NSNull null] ];
    

    I personally recommend to use a specific value like 0 instead of null or nil in your design of your code, but sometimes you need to add null.

    There is a good explanation from this Apple reference.

提交回复
热议问题