是什么导致这次崩溃?

时间:2011-03-20 20:57:31

标签: objective-c crash

在我的应用程序中,每次应用程序启动时都会显示UIAlertView,如果我没有单击“关闭”按钮,一切正常,但如果我单击“关闭”按钮,应用程序将崩溃大约3秒后面。

我从控制台获得了崩溃日志,如果有人知道它崩溃的原因请告诉我

  2011-03-20 15:47:05.833 App[8080:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSCFString 0x6e04920> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mystatsbutton.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x01a71be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x01bc65c2 objc_exception_throw + 47
    2   CoreFoundation                      0x01a71b21 -[NSException raise] + 17
    3   Foundation                          0x001016cf _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x0010163d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x005808d6 -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x019e82cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x0057f2ed -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x00581081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x00439a94 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x00437709 -[UIViewController loadView] + 120
    11  UIKit                               0x004375e3 -[UIViewController view] + 56
    12  App                            0x000084e2 -[LoadupView endview] + 132
    13  Foundation                          0x0011f7a5 __NSFireTimer + 125
    14  CoreFoundation                      0x01a52fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
    15  CoreFoundation                      0x01a54594 __CFRunLoopDoTimer + 1220
    16  CoreFoundation                      0x019b0cc9 __CFRunLoopRun + 1817
    17  CoreFoundation                      0x019b0240 CFRunLoopRunSpecific + 208
    18  CoreFoundation                      0x019b0161 CFRunLoopRunInMode + 97
    19  GraphicsServices                    0x02349268 GSEventRunModal + 217
    20  GraphicsServices                    0x0234932d GSEventRun + 115
    21  UIKit                               0x0039842e UIApplicationMain + 1160
    22  App                            0x000022de main + 84
    23  App                            0x00002281 start + 53
)
terminate called after throwing an instance of 'NSException'

4 个答案:

答案 0 :(得分:3)

从错误消息中,您似乎正在从笔尖加载视图控制器,其中笔尖正在尝试将某些内容连接到名为mystatsbutton的插座,但该类不包含插座那个名字。

答案 1 :(得分:3)

很可能你的内存被某种方式破坏了 - 你认为在加载相关程序时你知道mystatsbutton碰巧是一个NSString的东西,而不是你NIB图中的某个对象。< / p>

这可能由于几个原因而发生。通常,这意味着您在释放对象后使用它。哇,你的引用计数可能不正确。尝试在启用僵尸的情况下运行。

也可能是您已将指针值指定为您不想要的对象。插图:UIView * view = [NSString string];

它也可能是不那么明显的东西,例如你忘了在解除分配时删除一个观察者。

这些是更常见的原因。这可能是一个好的开始。

删除所有编译器警告(使用高设置)以及静态分析器问题也是一个好主意。

答案 2 :(得分:1)

您可以发布主要的UIViewController接口和实现吗?

看起来您没有将IBOutlet连接到名为mystatsbutton的属性。

答案 3 :(得分:1)

查看您的XIB并确保它没有灰色(Xcode 3.x) mystatsbutton。只需确保您的XIB上没有引用它。如果有参考,请删除它,你应该好好去。

相关问题