Skip navigation.
 
mlRe: Problems with [NSArray count]
FROM : Andy Lee
DATE : Tue Apr 22 23:19:55 2008

On Apr 22, 2008, at 5:03 PM, Peter Browne wrote:
> The docs tell me that [NSArray count] returns an NSUInteger, but 
> exactly WHAT one of these is, or how I use it is baffling me.


You could do a search using the built-in documentation browser in 
Xcode (it's in the Help menu).  Alternatively, Google would seem an 
obvious thing to try -- it turns up a number of relevant documents.

>     int i = [myArray count];
>
> crashes out, and I've tried various other types of variable to no 
> avail. Any thoughts? Am I missing something blindingly obvious here?


My first guess would be that myArray was not properly retained and was 
deallocated before you sent the count message.  You may want to review 
the memory management rules, especially if you're quite rusty: <http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html
>.

Also, are you sure that's the line you're crashing on?  Do any error 
messages get written to the console?

--Andy

Related mailsAuthorDate
mlProblems with [NSArray count] Peter Browne Apr 22, 23:03
mlRe: Problems with [NSArray count] Shawn Erickson Apr 22, 23:10
mlRe: Problems with [NSArray count] Shawn Erickson Apr 22, 23:14
mlRe: Problems with [NSArray count] David Duncan Apr 22, 23:15
mlRe: Problems with [NSArray count] Andy Lee Apr 22, 23:19
mlRe: Problems with [NSArray count] Peter Browne Apr 22, 23:45
mlRe: Problems with [NSArray count] Hamish Allan Apr 22, 23:57
mlRe: Problems with [NSArray count] Shawn Erickson Apr 23, 00:04
mlRe: Problems with [NSArray count] David Duncan Apr 23, 01:08