IPhone "tallying" frustration?

Well, I know that I must be missing something obvious. Here's a sample code (which, when executed in the viewDidLoad block, unexpectedly crashes ... no error is output to the debug console).

NSMutableArray *bs = [NSMutableArray arrayWithCapacity:10];
[bs addObject:[NSNumber numberWithInteger: 2]];
NSLog(@"%@", [bs count]);
[bs release];

What am I missing?

Oh ... and in case someone wonders, this code is just trying to figure out why I can't get the NSMutableArray score, which really matters somewhere else in the program.

+3
source share
2 answers

[mutableArray count] NSUInteger. NSLog % @, NSString. Obj-C , :

NSLog(@"%u", [bs count]); // Uses %u specifier which means unsigned int

, . :
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265-SW1

, . , release/autorelease , // . , , , , .

+8

!

arrayWithCapacity:10 autorelease d, , . , -1, ! ( )

, , , alloc copy, , ! (, , )

+5

Source: https://habr.com/ru/post/1747280/


All Articles