iPhone 中的对象处理错误,在 UITabView 中选择选项卡并崩溃

发布于 2024-10-19 08:35:58 字数 4422 浏览 2 评论 0原文

大家好,我正在创建一个选项卡视图应用程序,在一个选项卡中我有 7 个文本字段,我试图使用“保存”按钮保存其信息。在controller.h 文件中的对象和实际文本字段之间建立连接后,当我选择其中包含所有这些内容的选项卡时,应用程序崩溃并转到跳板。我在这里进行了调试:

2011-02-23 08:49:02.522 Tow Boat 911[19138:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e0d1d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key colour.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00ec6be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00cbb5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x00ec6b21 -[NSException raise] + 17
    3   Foundation                          0x000286cf _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x0002863d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x004a78d6 -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00e3d2cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x004a62ed -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x004a8081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x00360a94 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x0035e709 -[UIViewController loadView] + 120
    11  UIKit                               0x0035e5e3 -[UIViewController view] + 56
    12  UIKit                               0x00371230 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
    13  UIKit                               0x0036fd86 -[UITabBarController transitionFromViewController:toViewController:] + 64
    14  UIKit                               0x00371b7e -[UITabBarController _setSelectedViewController:] + 263
    15  UIKit                               0x003719ed -[UITabBarController _tabBarItemClicked:] + 352
    16  UIKit                               0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    17  UIKit                               0x004ae1f2 -[UITabBar _sendAction:withEvent:] + 422
    18  UIKit                               0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    19  UIKit                               0x0033f1b5 -[UIControl sendAction:to:forEvent:] + 67
    20  UIKit                               0x00341647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    21  UIKit                               0x0033f16c -[UIControl sendActionsForControlEvents:] + 49
    22  UIKit                               0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    23  UIKit                               0x0033f1b5 -[UIControl sendAction:to:forEvent:] + 67
    24  UIKit                               0x00341647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    25  UIKit                               0x003401f4 -[UIControl touchesEnded:withEvent:] + 458
    26  UIKit                               0x002d50d1 -[UIWindow _sendTouchesForEvent:] + 567
    27  UIKit                               0x002b637a -[UIApplication sendEvent:] + 447
    28  UIKit                               0x002bb732 _UIApplicationHandleEvent + 7576
    29  GraphicsServices                    0x016dda36 PurpleEventCallback + 1550
    30  CoreFoundation                      0x00ea8064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    31  CoreFoundation                      0x00e086f7 __CFRunLoopDoSource1 + 215
    32  CoreFoundation                      0x00e05983 __CFRunLoopRun + 979
    33  CoreFoundation                      0x00e05240 CFRunLoopRunSpecific + 208
    34  CoreFoundation                      0x00e05161 CFRunLoopRunInMode + 97
    35  GraphicsServices                    0x016dc268 GSEventRunModal + 217
    36  GraphicsServices                    0x016dc32d GSEventRun + 115
    37  UIKit                               0x002bf42e UIApplicationMain + 1160
    38  Tow Boat 911                        0x00001df8 main + 102
    39  Tow Boat 911                        0x00001d89 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.

提前感谢大家的帮助!

Hey everyone, I'm creating a tab-view application, and in the one tab I have 7 textFields that I am trying to save the information for with a "Save" button. After making the connections between the objects in my controller.h file and the actual text fields, when I select the tab with all this stuff in it, the application crashes and goes to the springboard. I have the debug here:

2011-02-23 08:49:02.522 Tow Boat 911[19138:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4e0d1d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key colour.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00ec6be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00cbb5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x00ec6b21 -[NSException raise] + 17
    3   Foundation                          0x000286cf _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x0002863d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x004a78d6 -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00e3d2cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x004a62ed -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x004a8081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x00360a94 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x0035e709 -[UIViewController loadView] + 120
    11  UIKit                               0x0035e5e3 -[UIViewController view] + 56
    12  UIKit                               0x00371230 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
    13  UIKit                               0x0036fd86 -[UITabBarController transitionFromViewController:toViewController:] + 64
    14  UIKit                               0x00371b7e -[UITabBarController _setSelectedViewController:] + 263
    15  UIKit                               0x003719ed -[UITabBarController _tabBarItemClicked:] + 352
    16  UIKit                               0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    17  UIKit                               0x004ae1f2 -[UITabBar _sendAction:withEvent:] + 422
    18  UIKit                               0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    19  UIKit                               0x0033f1b5 -[UIControl sendAction:to:forEvent:] + 67
    20  UIKit                               0x00341647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    21  UIKit                               0x0033f16c -[UIControl sendActionsForControlEvents:] + 49
    22  UIKit                               0x002b0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    23  UIKit                               0x0033f1b5 -[UIControl sendAction:to:forEvent:] + 67
    24  UIKit                               0x00341647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    25  UIKit                               0x003401f4 -[UIControl touchesEnded:withEvent:] + 458
    26  UIKit                               0x002d50d1 -[UIWindow _sendTouchesForEvent:] + 567
    27  UIKit                               0x002b637a -[UIApplication sendEvent:] + 447
    28  UIKit                               0x002bb732 _UIApplicationHandleEvent + 7576
    29  GraphicsServices                    0x016dda36 PurpleEventCallback + 1550
    30  CoreFoundation                      0x00ea8064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    31  CoreFoundation                      0x00e086f7 __CFRunLoopDoSource1 + 215
    32  CoreFoundation                      0x00e05983 __CFRunLoopRun + 979
    33  CoreFoundation                      0x00e05240 CFRunLoopRunSpecific + 208
    34  CoreFoundation                      0x00e05161 CFRunLoopRunInMode + 97
    35  GraphicsServices                    0x016dc268 GSEventRunModal + 217
    36  GraphicsServices                    0x016dc32d GSEventRun + 115
    37  UIKit                               0x002bf42e UIApplicationMain + 1160
    38  Tow Boat 911                        0x00001df8 main + 102
    39  Tow Boat 911                        0x00001d89 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.

Thanks everyone for any help in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白芷 2024-10-26 08:35:58

由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[ setValue:forUndefinedKey:]:此类与键颜色的键值编码不兼容。

在这种情况下,请检查以下内容:

  1. 确保您尝试访问 ie color 的键没有拼写错误。

  2. 您尝试访问的类属性(即颜色)应该符合键值。您可以将属性声明为标头中的属性,并在实现文件中综合相同的属性。不要更改属性声明中 getter 和 setter 的默认名称。默认方法名称/签名符合 KVC。
    Apple 关于 KVC 的文档涵盖了访问器方法代码: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/Overview.html

  3. 如果您使用核心数据,请确保正在访问的属性存在于相应的头文件,并且在实现文件中也有其代码。您可能稍后将此属性添加到模型中,但尚未更新生成的头文件和实现文件。

看到这篇文章没有答案,所以我想我会做出一个可能对其他人有帮助的回复。

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key colour.

In this case check the following:

  1. Ensure that you have not misspelled the key you are trying to access i.e. colour.

  2. The class attribute you are trying to access i.e. colour should be Key Value compliant. You can have the attribute declared as a property in header and synthesize the same in the implementation file. Do not change the default name for the getter and setter in the property declaration. The default method name/signature is KVC compliant.
    Apple documentation on KVC covering the accessor method code: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/Overview.html

  3. If you are using core data ensure that the property being accessed is present in the corresponding header file and also has its code in the implementation file. It can happen that you have added this property later to the model and have not updated the generated header and implementation file.

Came across this post without an answer so thought I would put a response which may help someone else.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文