开发者

Init array with bool values

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜