Nav Link On

iPhone Dev Forums > General Development > SDK Coding Help > NSMutableArray count causing application crash

Reply

 

LinkBack Thread Tools Display Modes
Old 01-29-2010, 09:09 PM   #1 (permalink)
Junior Member
Default Avatar
 
Join Date: Jan 2010
Posts: 1
Default NSMutableArray count causing application crash

Hi,

Thanks in advance to all of those that can help me out here. I'm having all sorts of problems with NSMutableArrays. This is the code I am using:

Code:

You must Login or Register to view and contribute code! This is done to increase participation in helping one another out, if you have been helped please pass on the favor.

- (void)viewDidLoad {
	NSMutableArray *myArray = [[NSMutableArray alloc] initWithCapacity:1];
	[myArray addObject:@"Object"];
	NSLog(@"About to count");
	NSLog(@"Count = %@", [myArray count]);
	[myArray release];
    [super viewDidLoad];
}
The count causes the application to crash everytime. Here is the output from the Console:

[Session started at 2010-01-29 22:05:26 +0000.]
2010-01-29 22:05:28.037 Tester[3336:207] About to count

That is it, the application crashes after this. I have tried this is an NSArray as well with the same outcome. I have also tried using either NSArray or NSMutableArray in some other applications that I had previously written (and worked) and it caused the same problem. Weirdly, NSLog is able to read the contents of an array but not count it. However, in another place I made if statement triggered by a comparison between an Array entry and another NSString. Despite the strings definitely matching the if statement does not run. Please help, I'm completely stuck and it's driving me mad.
Edams51 is offline   Reply With Quote
Old 01-30-2010, 05:03 AM   #2 (permalink)
Administrator
 
MarkHernandez's Avatar
 
Join Date: Mar 2008
Location: San Diego, CA
Posts: 508
Default

If I were in your shoes I would go and find working sample code that accomplishes what I'm trying to do and copy it verbatim and move on without caring much about why this particular way of doing things is crashing.
MarkHernandez is offline   Reply With Quote
Old 01-31-2010, 07:15 PM   #3 (permalink)
Junior Member
Default Avatar
 
Join Date: Jan 2010
Posts: 1
Default

try replacing %@ with %d, as the count method is returning an integer
Whitby is offline   Reply With Quote
Reply

iPhone Dev Forums > General Development > SDK Coding Help


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 RC1