Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-30-2009, 08:09 PM   #1 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 4
Default NSArray crashes on count

Hi all,

I'm stuck on something that I can't figure out.

I've got an NSArray. It's created with [[NSArray arrayWithArray:someotherrray] retain];

I pass it in to another object.

From within that object, I'm able to read the array just fine. Calling "NSLog(@"%@",myArray) shows me the array contents.

But, if I call [myArray count], the program crashes with no explanation. No EXEC_BAD_ACCESS, nothing. Just back to the GNU GDB discalaimer in the debugger console.

Any ideas?
mikejstein is offline   Reply With Quote
Old 11-30-2009, 10:28 PM   #2 (permalink)
Programming Wizard
 
slahteine's Avatar
 
Join Date: Oct 2008
Location: Northampton, MA USA
Age: 45
Posts: 193
Send a message via AIM to slahteine Send a message via Yahoo to slahteine Send a message via Skype™ to slahteine
Default

Quote:
Originally Posted by mikejstein View Post
But, if I call [myArray count], the program crashes with no explanation. No EXEC_BAD_ACCESS, nothing.
It could be getting trounced by something else, affecting some of the data structure, but not the contents. Try moving the declaration to another place - for example, make it a global temporarily, and see if the crash still occurs. If so, HMM! - but if not, then look around for buffer overruns and things that could be trashing memory beyond where they should.
__________________
|
| I wrote ChordCalc ... A cool fretboard calculator.
|

slahteine is offline   Reply With Quote
Old 11-30-2009, 10:30 PM   #3 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,129
Default

1. What is the purpose of using a convenience method if you are just going to manually retain anyway?

2. What is the line of code that crashes?
__________________
BriTer Ideas LLC - Code review, consulting, development. PM for pricing.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
BrianSlick is offline   Reply With Quote
Old 11-30-2009, 10:44 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

It's very strange to crash with no message at all - I'd check to make sure the debugger didn't stop on the error and prevent the error from getting printed (run > debugger) and check the OSX console for any hints (path: /Applications/Utilities/Console).
__________________

Free Games!
smasher is offline   Reply With Quote
Old 12-01-2009, 04:27 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 57
Default

mmm..this is a strange error.
post here the code. maybe we can help you.
ignazioc is offline   Reply With Quote
Old 02-10-2010, 06:54 PM   #6 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 16
Default

Same thing happening with me. I can't count but I can use objectAtIndex: and get the objects from the array. No error message displayed in console just cuts out of the simulator.
MMan is offline   Reply With Quote
Old 02-11-2010, 07:21 AM   #7 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Manchester, UK
Posts: 24
Default

I'm no expert (at all) but I've found that this will happen if you try to put it into a string in the wrong way, for example:

Code:
NSLog([NSString stringWithFormat:@"%@", [shotList count]]);
Will crash with no error.

Code:
NSLog([NSString stringWithFormat:@"%i", [shotList count]]);
Will work a charm

Hope that helps,
Ian
ianian is offline   Reply With Quote
Old 07-12-2010, 02:46 PM   #8 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 1
Default

Quote:
Originally Posted by ianian View Post
I'm no expert (at all) but I've found that this will happen if you try to put it into a string in the wrong way, for example:

Code:
NSLog([NSString stringWithFormat:@"%@", [shotList count]]);
Will crash with no error.

Code:
NSLog([NSString stringWithFormat:@"%i", [shotList count]]);
Will work a charm

Hope that helps,
Ian
Same problem, looked for hours and could not find it or logically explain the crash.

But this one solved it !

Thanx ianian!
brmz is offline   Reply With Quote
Reply

Bookmarks

Tags
count, crash, nsarray

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



» Advertisements
» Online Users: 346
19 members and 327 guests
ADY, Alsahir, Dani77, e2applets, JasonR, keeshux, mer10, Monstertaco, piesia, prchn4christ, Promo Dispenser, Robiwan, sebasx, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,759
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:26 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0