开发者

Init array with bool values

开发者 https://www.devze.com 2022-12-29 17:52 出处:网络
my attempt to init an array with a number of bool values using: [myArray initWithObjects:[NSNumber numberWithBool:YES],

my attempt to init an array with a number of bool values using:

[myArray initWithObjects:[NSNumber numberWithBool:YES], 
                         [NSNumber numberWithBool:YES], 
                         [NSNumber numberWithBool:YES],
                        开发者_开发问答 nil];

seems to fail since the debugger shows an empty array after this statement is carried out ... Any clues?


Make sure you are alloc-ing the object, as well, i.e.:

NSArray *myArray = [[NSArray alloc] initWithObjects:...];
...
[myArray release];

Or:

NSArray *myArray = [[[NSArray alloc] initWithObjects:...] autorelease];

Or:

NSArray *myArray = [NSArray arrayWithObjects:...];
0

精彩评论

暂无评论...
验证码 换一张
取 消