我开始编写iOS应用程序,但我突然遇到了问题。该程序按预期工作,我有一个单一的视图应用程序,导航栏标题为Title。当我编译它时,它没关系,但后来我决定"重新编辑"标题栏上写着你好。之后,我发现了一个错误,没有任何想法,因为它在这个错误之前的一分钟工作,唯一的变化就是标题栏的标题。
这是错误
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
[<MapViewController 0xa964410> setValue:forUndefinedKey:]: this class is not key
value coding-compliant for the key titleText.'
*** First throw call stack:
(
0 CoreFoundation 0x027a51e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x025248e5 objc_exception_throw + 44
2 CoreFoundation 0x02834fe1 -[NSException raise] + 17
3 Foundation 0x021e4d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x021511d7 _NSSetUsingKeyValueSetter + 88
5 Foundation 0x02150731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x021b2b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x0149b1f4 -[UIRuntimeOutletConnection connect] + 106
8 libobjc.A.dylib 0x025367de -[NSObject performSelector:] + 62
9 CoreFoundation 0x027a076a -[NSArray makeObjectsPerformSelector:] + 314
10 UIKit 0x01499d4d -[UINib instantiateWithOwner:options:] + 1417
11 UIKit 0x013026f5 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
12 UIKit 0x01302e9d -[UIViewController loadView] + 302
13 UIKit 0x013030d3 -[UIViewController loadViewIfRequired] + 78
14 UIKit 0x013035d9 -[UIViewController view] + 35
15 UIKit 0x01223267 -[UIWindow addRootViewControllerViewIfPossible] + 66
16 UIKit 0x012235ef -[UIWindow _setHidden:forced:] + 312
17 UIKit 0x0122386b -[UIWindow _orderFrontWithoutMakingKey] + 49
18 UIKit 0x0122e3c8 -[UIWindow makeKeyAndVisible] + 65
19 Anchor-It 0x00005a39 -[AppDelegate application:didFinishLaunchingWithOptions:] + 585
20 UIKit 0x011de14f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
21 UIKit 0x011deaa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
22 UIKit 0x011e3667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
23 UIKit 0x011f7f92 -[UIApplication handleEvent:withNewEvent:] + 3517
24 UIKit 0x011f8555 -[UIApplication sendEvent:] + 85
25 UIKit 0x011e5250 _UIApplicationHandleEvent + 683
26 GraphicsServices 0x0381df02 _PurpleEventCallback + 776
27 GraphicsServices 0x0381da0d PurpleEventCallback + 46
28 CoreFoundation 0x02720ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
29 CoreFoundation 0x027209db __CFRunLoopDoSource1 + 523
30 CoreFoundation 0x0274b68c __CFRunLoopRun + 2156
31 CoreFoundation 0x0274a9d3 CFRunLoopRunSpecific + 467
32 CoreFoundation 0x0274a7eb CFRunLoopRunInMode + 123
33 UIKit 0x011e2d9c -[UIApplication _run] + 840
34 UIKit 0x011e4f9b UIApplicationMain + 1225
35 Anchor-It 0x00005dbd main + 141
36 libdyld.dylib 0x03f5e701 start + 1
37 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
答案 0 :(得分:1)
查看堆栈跟踪的这一部分:
3 Foundation 0x021e4d9e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x021511d7 _NSSetUsingKeyValueSetter + 88
5 Foundation 0x02150731 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
6 Foundation 0x021b2b0a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
7 UIKit 0x0149b1f4 -[UIRuntimeOutletConnection connect] + 106
您的.xib或情节提要文件中的连接错误。视图加载过程试图将某些内容连接到某些不存在的插座,从而导致抛出异常。关于究竟什么连接不好的更多信息来自异常本身:
[<MapViewController 0xa964410> setValue:forUndefinedKey:]: this class is not key
value coding-compliant for the key titleText.'
因此,您已获得MapViewController
的实例,UIRuntimeOutletConnection
(视图加载系统的一部分)正在尝试设置名为titleText
的商店。 MapViewController
显然没有titleText
属性。这可能发生,因为您曾经有过这样的属性但是删除了它,或者因为您将视图控制器的类从其他东西(具有这样的属性)更改为MapViewController
(它没有),等