NSMutableArray Crashes App

0

I have a custom class "Person".

Several Person objects have been created and added to an NSMutableArray called 'personArray'.

I'm then going to pass one of these to the next view, called userView.

These have all been Allocated and Initialised.

The code I am using is:

[userView setPerson:[personArray objectAtIndex:indexPath.row]];

The app crashes when I click a table row, with this in the debugger:

Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found).
warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/rich/Library/Application Support/iPhone Simulator/User/Applications/C587B508-F75C-4D8A-9C17-86BF49C99B22/Twitter.app/Twitter', process 3792.

Any help with this would be greatly appreciated!

Rich :)

edit

I got this from the Unexpected Quit report problem box:

Process:         Twitter [4355]
Path:            /Users/rich/Library/Application Support/iPhone Simulator/User/Applications/74BFCE7A-84FF-4D5D-80B7-1620F0D28A20/Twitter.app/Twitter
Identifier:      Twitter
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  launchd [83]

Interval Since Last Report:          22503 sec
Crashes Since Last Report:           3
Per-App Interval Since Last Report:  0 sec
Per-App Crashes Since Last Report:   2

Date/Time:       2009-06-12 18:16:52.121 +0100
OS Version:      Mac OS X 10.5.7 (9J61)
Report Version:  6
Anonymous UUID:  1C202A26-2A1A-4A4B-AAFA-59116B0EC46E

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000020
Crashed Thread:  0

Application Specific Information:
iPhone Simulator 1.0 (70), iPhone OS 2.0 (5A345)

Thread 0 Crashed:
0   libobjc.A.dylib                 0x9344c688 objc_msgSend + 24
1   Twitter                         0x00006843 -[UserViewController setPerson:] + 55 (UserViewController.m:56)
2   Twitter                         0x000030bb -[RootViewController tableView:didSelectRowAtIndexPath:] + 261 (RootViewController.m:85)
3   UIKit                           0x30a9cd92 -[UITableView(_UITableViewPrivate) _sendSelectionDidChange] + 97
4   UIKit                           0x30aa3eb1 -[UITableView touchesEnded:withEvent:] + 411
5   UIKit                           0x30a75c0b -[UIWindow sendEvent:] + 454
6   UIKit                           0x30a65e07 -[UIApplication sendEvent:] + 269
7   UIKit                           0x30a6522a _UIApplicationHandleEvent + 4407
8   GraphicsServices                0x31699522 SendEvent + 35
9   GraphicsServices                0x3169b88c PurpleEventTimerCallBack + 276
10  com.apple.CoreFoundation        0x90680595 CFRunLoopRunSpecific + 3141
11  com.apple.CoreFoundation        0x90680c78 CFRunLoopRunInMode + 88
12  GraphicsServices                0x31699d38 GSEventRunModal + 217
13  GraphicsServices                0x31699dfd GSEventRun + 115
14  UIKit                           0x30a5dadb -[UIApplication _run] + 440
15  UIKit                           0x30a68ce4 UIApplicationMain + 1258
16  Twitter                         0x000028e4 main + 102 (main.m:14)
17  Twitter                         0x00002852 start + 54

Thread 1:
0   libSystem.B.dylib               0x91d13286 mach_msg_trap + 10
1   libSystem.B.dylib               0x91d1aa7c mach_msg + 72
2   com.apple.CoreFoundation        0x9068004e CFRunLoopRunSpecific + 1790
3   com.apple.CoreFoundation        0x90680c78 CFRunLoopRunInMode + 88
4   WebCore                         0x32a8a450 RunWebThread + 384
5   libSystem.B.dylib               0x91d44155 _pthread_start + 321
6   libSystem.B.dylib               0x91d44012 thread_start + 34

Thread 2:
0   libSystem.B.dylib               0x91d13286 mach_msg_trap + 10
1   libSystem.B.dylib               0x91d1aa7c mach_msg + 72
2   GraphicsServices                0x3169ce0a EventReceiveThread + 467
3   libSystem.B.dylib               0x91d44155 _pthread_start + 321
4   libSystem.B.dylib               0x91d44012 thread_start + 34

Thread 3:
0   libSystem.B.dylib               0x91d13286 mach_msg_trap + 10
1   libSystem.B.dylib               0x91d1aa7c mach_msg + 72
2   com.apple.CoreFoundation        0x9068004e CFRunLoopRunSpecific + 1790
3   com.apple.CoreFoundation        0x90680c78 CFRunLoopRunInMode + 88
4   com.apple.Foundation            0x92f78530 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 320
5   com.apple.Foundation            0x92f14e0d -[NSThread main] + 45
6   com.apple.Foundation            0x92f149b4 __NSThread__main__ + 308
7   libSystem.B.dylib               0x91d44155 _pthread_start + 321
8   libSystem.B.dylib               0x91d44012 thread_start + 34

Thread 4:
0   libSystem.B.dylib               0x91d13286 mach_msg_trap + 10
1   libSystem.B.dylib               0x91d1aa7c mach_msg + 72
2   com.apple.CoreFoundation        0x9068004e CFRunLoopRunSpecific + 1790
3   com.apple.CoreFoundation        0x90680c78 CFRunLoopRunInMode + 88
4   com.apple.CFNetwork             0x907c2298 CFURLCacheWorkerThread(void*) + 388
5   libSystem.B.dylib               0x91d44155 _pthread_start + 321
6   libSystem.B.dylib               0x91d44012 thread_start + 34

Thread 5:
0   libSystem.B.dylib               0x91d626fa select$DARWIN_EXTSN + 10
1   libSystem.B.dylib               0x91d44155 _pthread_start + 321
2   libSystem.B.dylib               0x91d44012 thread_start + 34

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x00494630  ebx: 0x9344cc8f  ecx: 0x934fe514  edx: 0x00000000
  edi: 0x004a8420  esi: 0x00000040  ebp: 0xbfffe0b8  esp: 0xbfffe078
   ss: 0x0000001f  efl: 0x00010206  eip: 0x9344c688   cs: 0x00000017
   ds: 0x0000001f   es: 0x0000001f   fs: 0x00000000   gs: 0x00000037
  cr2: 0x00000020

Binary Images:
    0x1000 -     0x7fff +Twitter ??? (???) <0f292e372486bfc6311c226b48178dc2> /Users/rich/Library/Application Support/iPhone Simulator/User/Applications/74BFCE7A-84FF-4D5D-80B7-1620F0D28A20/Twitter.app/Twitter
   0x10000 -    0x11fff +liboainject.dylib ??? (???) <0d83c3f81b6733d13a50867064b845dd> /Developer/Applications/Instruments.app/Contents/PlugIns/MemoryPlugin.bundle/Contents/Resources/liboainject.dylib
   0x16000 -    0x16fff +libsimshim.dylib ??? (???) <f37682fd161d73a66f64118e79a844c0> /Developer/Library/PrivateFrameworks/InstrumentsPlugIn.framework/Resources/libsimshim.dylib
   0x1b000 -    0x1ffff +libGIF.dylib ??? (???) <b077a36cf9345ac7e0be39eb7faae809> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/ImageIO.framework/libGIF.dylib
   0x25000 -    0x25fff +DataMigration ??? (???) <8190b94df60a16625c1d0a711dfce810> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/DataMigration.framework/DataMigration
   0x46000 -    0x72fff  com.apple.SystemConfiguration 1.9.5 (1.9.5) <8916c48065cc8a7274fe7c98a8bc755c> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
   0x8c000 -   0x1a1fe3 +AudioToolbox ??? (???) <47bc2da19d097da44ce3a3212ca41f27> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
  0x200000 -   0x221fea +libJPEG.dylib ??? (???) <d5b1728d176d53f0502919d4c779e360> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/ImageIO.framework/libJPEG.dylib
  0x22a000 -   0x245fe7 +libPng.dylib ??? (???) <ff6791e33bbf860cd30510587920c673> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/ImageIO.framework/libPng.dylib
  0x24d000 -   0x251ffc +libGFXShared.dylib ??? (???) <757e5613a4dccfe0045b13e5f7108f9f> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/OpenGLES.framework/libGFXShared.dylib
  0x257000 -   0x296ffe +libGLImage.dylib ??? (???) <6df300f534f23e8aeef39d5f2f730028> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/OpenGLES.framework/libGLImage.dylib
  0x300000 -   0x30aff3 +CoreVideo ??? (???) <23a4f9dc9242912b2d0a7ff893a556b7> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/CoreVideo.framework/CoreVideo
  0x313000 -   0x38ffeb  com.apple.audio.CoreAudio 3.1.1 (3.1.1) <41cb72c5651cf533122fb65c464b3be2> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
  0x500000 -   0x543fe6 +libCGFreetype.A.dylib ??? (???) <5d1bec00b54062913bada794887f894a> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Resources/libCGFreetype.A.dylib
  0x572000 -   0x599fe7 +libRIP.A.dylib ??? (???) <595f583c272aa909e840f93e644b5af8> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreGraphics.framework/Resources/libRIP.A.dylib
  0x856000 -   0xe74fc2 +libGLProgrammability.dylib ??? (???) <1fca696da40a8fe2017deb05b0ca9f60> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/OpenGLES.framework/libGLProgrammability.dylib
0x30894000 - 0x308a0fff +AppSupport ??? (???) <7136ddcdd71ba8ac87a956711a7d3052> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport
0x30a54000 - 0x30c9dfe4 +UIKit ??? (???) <ed41052bca54b8707642ac44a3a72531> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit
0x30fce000 - 0x311d3fff  com.apple.CoreGraphics 1.359.4 (???) <f58e36a5e01783887c3d4b6e3a0e62fc> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
0x3124f000 - 0x3125dfff +OpenGLES ??? (???) <d132e8601dc84cd1a86f12eb5f1c6695> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/OpenGLES.framework/OpenGLES
0x31290000 - 0x31350ff3 +JavaScriptCore ??? (???) <ef23a07fd02335c6304c999c7c891f31> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
0x31696000 - 0x3169eff1 +GraphicsServices ??? (???) <068d0945d990a619e47e5915c318903e> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x31707000 - 0x31747fe7 +ImageIO ??? (???) <d3a95af0a5939e11ea440f12904e7602> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/ImageIO.framework/ImageIO
0x3179c000 - 0x317dafef +libTIFF.dylib ??? (???) <9cb64be0480b2a32a9e5f5eb3f0cfda0> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/ImageIO.framework/libTIFF.dylib
0x318da000 - 0x318dcfff +IAP ??? (???) <6d754b165e29ec239f421fc9871720e3> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/IAP.framework/IAP
0x31b9a000 - 0x31bb2fff +AddressBook ??? (???) <f341118239be07ba49db806c49fe5f8d> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/AddressBook.framework/AddressBook
0x31e7f000 - 0x31ef3fe7 +QuartzCore ??? (???) <6c4bfbe306a67a09ba333ae2041aa543> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore
0x326a4000 - 0x32b13fff +WebCore ??? (???) <6d001f5b0ea23a29efa0a52413954387> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/WebCore.framework/WebCore
0x32dd5000 - 0x32e44ff1 +WebKit ??? (???) <e0b7d6aeeed7ca9f595331868c55a14e> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/WebKit.framework/WebKit
0x33b25000 - 0x33b2cffd +SpringBoardServices ??? (???) <c051be030a97bd82cbc95ac04b4802e9> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices
0x8fe00000 - 0x8fe2db43  dyld 97.1 (???) <100d362e03410f181a34e04e94189ae5> /usr/lib/dyld
0x90003000 - 0x90027fff  libxslt.1.dylib ??? (???) <0a9778d6368ae668826f446878deb99b> /usr/lib/libxslt.1.dylib
0x9060d000 - 0x90740fef  com.apple.CoreFoundation 6.5.6 (476.18) <2d52bab73660117571bd6486dc318f8e> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x907bf000 - 0x90863fec  com.apple.CFNetwork 438.10 (438.12) <fde64bbb20532794396fb21911ccaa98> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x908f9000 - 0x909daff7  libxml2.2.dylib ??? (???) <068cab13eb4608a7c6a5fad807ee0e33> /usr/lib/libxml2.2.dylib
0x90a20000 - 0x90aa7ff7  libsqlite3.0.dylib ??? (???) <3334ea5af7a911637413334154bb4100> /usr/lib/libsqlite3.0.dylib
0x91d12000 - 0x91e79ff3  libSystem.B.dylib ??? (???) <b47c8e6e45aef620730710a732bf1930> /usr/lib/libSystem.B.dylib
0x92194000 - 0x92194ffa  com.apple.CoreServices 32 (32) <2760719f7a81e8c2bdfd15b0939abc29> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x92195000 - 0x9219cfe9  libgcc_s.1.dylib ??? (???) <28a7cbc3a5ca2982d124668306f422d9> /usr/lib/libgcc_s.1.dylib
0x92570000 - 0x92586fff  com.apple.DictionaryServices 1.0.0 (1.0.0) <7e9ff586b5c9d02b09e2a5527d98524f> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
0x92593000 - 0x926ccff7  libicucore.A.dylib ??? (???) <cac059ebdac7d9a63ee0f7a648c9f6cf> /usr/lib/libicucore.A.dylib
0x92a4c000 - 0x92a6afff  libresolv.9.dylib ??? (???) <b5b1527c2d99495ad5d507ab0a4ea872> /usr/lib/libresolv.9.dylib
0x92e33000 - 0x92ebfff7  com.apple.framework.IOKit 1.5.2 (???) <97b9f9d584f48891377f0481b9104434> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x92f0a000 - 0x93186fe7  com.apple.Foundation 6.5.8 (677.24) <aa84b0383891378c348ffa4a94853082> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x932f4000 - 0x932fbffe  libbsm.dylib ??? (???) <5582985a86ea36504cca31788bccf963> /usr/lib/libbsm.dylib
0x93437000 - 0x93517fff  libobjc.A.dylib ??? (???) <7b92613fdf804fd9a0a3733a0674c30b> /usr/lib/libobjc.A.dylib
0x93d17000 - 0x93d74ffb  libstdc++.6.dylib ??? (???) <6106b1f2b0b303b06ae476253dbb5f3f> /usr/lib/libstdc++.6.dylib
0x941a0000 - 0x941a8fff  com.apple.DiskArbitration 2.2.1 (2.2.1) <75b0c8d8940a8a27816961dddcac8e0f> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x941ad000 - 0x94267fe3  com.apple.CoreServices.OSServices 227 (227) <30cebcb68b1b571df7d77474e0c31556> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x948c0000 - 0x94909fef  com.apple.Metadata 10.5.2 (398.25) <e0572f20350523116f23000676122a8d> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x951e0000 - 0x951eeffd  libz.1.dylib ??? (???) <545ca09467025f77131cfac09d8b9375> /usr/lib/libz.1.dylib
0x95f97000 - 0x96016ff5  com.apple.SearchKit 1.2.1 (1.2.1) <3140a605db2abf56b237fa156a08b28b> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x9601c000 - 0x96047fe7  libauto.dylib ??? (???) <42d8422dc23a18071869fdf7b5d8fab5> /usr/lib/libauto.dylib
0x96049000 - 0x9621affb  com.apple.security 5.0.5 (36371) <c13e0bb1acfdcf94be4d3ee118ef190e> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x96420000 - 0x964acff7  com.apple.LaunchServices 290.3 (290.6) <bdba267184df88bd5b8e2116ea903872> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x964ad000 - 0x964b1fff  libmathCommon.A.dylib ??? (???) /usr/lib/system/libmathCommon.A.dylib
0x968cc000 - 0x96ba6ff3  com.apple.CoreServices.CarbonCore 786.11 (786.13) <9e2d85d52e5e2951aa4dd53c48ccc52f> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x96bc0000 - 0x96beffe3  com.apple.AE 402.3 (402.3) <b13bfda0ad9314922ee37c0d018d7de9> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0xfffe8000 - 0xfffebfff  libobjc.A.dylib ??? (???) /usr/lib/libobjc.A.dylib
0xffff0000 - 0xffff1780  libSystem.B.dylib ??? (???) /usr/lib/libSystem.B.dylib

Does that help at all?

Thanks Rich

iphone
objective-c
cocoa-touch
nsmutablearray
asked on Stack Overflow Jun 12, 2009 by (unknown user) • edited Jun 13, 2009 by Corey Floyd

7 Answers

5

Just going out on a limb, but did you make sure to add nil as the last element in the array when you created it?

NSMutableArray *array = [NSMutableArray arrayWithObjects: @"one", @"two", @"three", @"four", nil];

answered on Stack Overflow Jun 12, 2009 by Tony Eichelberger
1

I've been hitting messages like this as well, and it's usually because the program is trying to access some memory location that has been released already.

Make sure your userView setPerson method is retaining the object (and releasing it in the dealloc).

Also, how are you creating & pushing your 2nd view controller? is it an instance variable or are you creating it each time?

answered on Stack Overflow Jun 12, 2009 by Ben Scheirman
1

Either person, userView, or personArray has been deallocated OR personArray is not as big as you think. You need to place breakpoints to find out which is the case.

You should follow the entire lifecycle of each object and make sure it is properly retained.

You can implement dealloc in custom classes and set breakpoints in there and make sure nothing gets deallocated that shouldn't.

Also try enabling NSZombie to see if it gets any messages.

answered on Stack Overflow Jun 12, 2009 by Corey Floyd
0

The NSMutableArray had objects added to it using 'addObject' within a fast enumeration loop.

answered on Stack Overflow Jun 12, 2009 by Rich
0

Looks to me like indexPath.row is not what you think it is, and is requesting an object that is out of bounds.

Have you tried logging with something like this:

NSLog(@"personArraysize: %u, object I'm accessing: %@", [personArray count], indexPath.row);
[userView setPerson:[personArray objectAtIndex:indexPath.row]];
answered on Stack Overflow Jun 12, 2009 by Aftermathew
0
  • Check if the objects, added to personArray are still valid and not autoreleased yet.
  • Check setPerson implementation, it may work with other objects, which are already autoreleased.
answered on Stack Overflow Jun 13, 2009 by Valerii Hiora
0

I got the same problem, I used NSArray (with nil at the end) but whenever I send objectAtIndex it crashes, today I found apple's core animation sample code, it uses NSArray as well, the initialization line is as follows:

names = [[NSArray arrayWithObjects:@"Item 1", @"Item 2", @"Item 3", @"Item 4", @"Item 5", nil] retain];

so I guess you should do it this way.

answered on Stack Overflow Sep 17, 2009 by (unknown user)

User contributions licensed under CC BY-SA 3.0