Iphone NSMutableArray应用程序崩溃

Iphone NSMutableArray应用程序崩溃,iphone,objective-c,cocoa-touch,nsmutablearray,Iphone,Objective C,Cocoa Touch,Nsmutablearray,我有一个自定义类的人 已创建多个Person对象并将其添加到名为“personArray”的NSMutableArray中 然后我将其中一个传递到下一个视图,称为userView 这些都已分配和初始化 我使用的代码是: [userView setPerson:[personArray objectAtIndex:indexPath.row]]; 在调试器中单击表行时,应用程序崩溃: Loading program into debugger… GNU gdb 6.3.50-20050815 (

我有一个自定义类的人

已创建多个Person对象并将其添加到名为“personArray”的NSMutableArray中

然后我将其中一个传递到下一个视图,称为userView

这些都已分配和初始化

我使用的代码是:

[userView setPerson:[personArray objectAtIndex:indexPath.row]];
在调试器中单击表行时,应用程序崩溃:

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.
在此方面的任何帮助都将不胜感激

里奇:

编辑

我从“意外退出报告”问题框中获得以下信息:

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
这有帮助吗


谢谢Rich,我也收到过类似的消息,这通常是因为程序试图访问一些已经释放的内存位置

确保userView setPerson方法保留该对象并在DealLocal中释放它


另外,您如何创建和推送第二视图控制器?它是一个实例变量还是您每次都在创建它?

只是在一个肢体上,但是您是否确保在创建它时将nil添加为数组中的最后一个元素


NSMUTABLEARRY*array=[NSMUTABLEARRY arrayWithObjects:@one、@two、@three、@four、nil]

NSMutableArray在快速枚举循环中使用“addObject”向其添加了对象。

在我看来,indexPath.row不是您所认为的那样,正在请求一个超出范围的对象

您是否尝试过使用以下方式登录:

NSLog(@"personArraysize: %u, object I'm accessing: %@", [personArray count], indexPath.row);
[userView setPerson:[personArray objectAtIndex:indexPath.row]];

person、userView或personArray都已解除分配,或者personArray没有您想象的那么大。您需要放置断点,以确定是哪种情况

您应该跟踪每个对象的整个生命周期,并确保它被正确保留

您可以在自定义类中实现dealloc,并在其中设置断点,并确保没有不应该取消分配的内容

还可以尝试启用NSZombie以查看它是否收到任何消息

检查添加到personArray的对象是否仍然有效且尚未自动删除。 检查setPerson实现,它可能与其他已自动删除的对象一起工作。
我也遇到了同样的问题,我在最后使用了NSArray和nil,但每当我发送objectAtIndex时,它就会崩溃,今天我发现苹果的核心动画示例代码,它也使用NSArray,初始化行如下所示:

名称=[[NSArray arrayWithObjects:@Item 1、@Item 2、@Item 3、@Item 4、@Item 5、nil]保留]


所以我想你应该这样做。

尝试添加一些NSLog。。。调用以查看它能走多远,调试输出不会告诉我调试输出没有多大帮助。这正是它启动时的表现。调试器在哪一行代码上停止?您可以发布堆栈跟踪吗?附加到程序的最后一行是在您的程序开始运行之前。如果它正在崩溃,没有迹象表明原因。你需要发布更多的调试器输出。好主意,这之前也让我绊倒了!NSMutableArray在快速枚举循环中使用“addObject”向其添加了对象。我已经尝试过了!indexPath.row是我选择的任何一行,personArray计数是3-这是正确的。引发msg_send异常的不是personArray。userView必须已解除分配。根据轨迹,动态创建视图控制器;然而这并不是问题所在,因为我已经注释掉了所有的导航代码,似乎是[personArray getObjectAtIndex]让它崩溃了:我相信情况就是这样。我没有在userView上调用setPerson方法,而是实现了一个接受Person对象的自定义初始化器。这似乎有效!谢谢大家的帮助!另外,我想知道为什么它会使事情变得复杂,难以理解,我使用Java已经好几年了,没有任何这些问题。