Changing name of ViewController causes app to crash?

2

I created a new View-based iPhone app in XCode (4.0) using iOS SDK 4.3. I then changed the name of the ViewController from MyProjectNameViewController to LoginViewController. I also replaced every single instance I could find of MyProjectNameViewController with LoginViewController, and I have double checked all of the links in interface builder.

Yet, when I try to run the app, It crashes:

2011-06-29 10:21:36.927 Monitoring[12580:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginViewController 0x4b26bf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key password.'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc05a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f14313 objc_exception_throw + 44
    2   CoreFoundation                      0x00dc04e1 -[NSException raise] + 17
    3   Foundation                          0x00792677 _NSSetUsingKeyValueSetter + 135
    4   Foundation                          0x007925e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5   UIKit                               0x0020e30c -[UIRuntimeOutletConnection connect] + 112
    6   CoreFoundation                      0x00d368cf -[NSArray makeObjectsPerformSelector:] + 239
    7   UIKit                               0x0020cd23 -[UINib instantiateWithOwner:options:] + 1041
    8   UIKit                               0x0020eab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9   UIKit                               0x000c4628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
    10  UIKit                               0x000c2134 -[UIViewController loadView] + 120
    11  UIKit                               0x000c200e -[UIViewController view] + 56
    12  UIKit                               0x00035d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
    13  MyProjectName                       0x000022c7 -[MyProjectNameAppDelegate application:didFinishLaunchingWithOptions:] + 135
    14  UIKit                               0x00012c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    15  UIKit                               0x00014d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    16  UIKit                               0x0001f617 -[UIApplication handleEvent:withNewEvent:] + 1533
    17  UIKit                               0x00017abf -[UIApplication sendEvent:] + 71
    18  UIKit                               0x0001cf2e _UIApplicationHandleEvent + 7576
    19  GraphicsServices                    0x00ff9992 PurpleEventCallback + 1550
    20  CoreFoundation                      0x00da1944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    21  CoreFoundation                      0x00d01cf7 __CFRunLoopDoSource1 + 215
    22  CoreFoundation                      0x00cfef83 __CFRunLoopRun + 979
    23  CoreFoundation                      0x00cfe840 CFRunLoopRunSpecific + 208
    24  CoreFoundation                      0x00cfe761 CFRunLoopRunInMode + 97
    25  UIKit                               0x000147d2 -[UIApplication _run] + 623
    26  UIKit                               0x00020c93 UIApplicationMain + 1160
    27  MyProjectName                       0x00002209 main + 121
    28  MyProjectName                       0x00002185 start + 53

What do I need to do to fix this?

iphone
xcode
cocoa-touch
ios4
uiviewcontroller
asked on Stack Overflow Jun 28, 2011 by DanielGibbs

5 Answers

3

Did you also rename the classes in your nibs/xibs?

The error message tells you that something wants access to a password via KVC, and the object it is called on (LoginViewController) does not provide KVC-compliant access to password. Did you fiddle with the password getters/setters?

answered on Stack Overflow Jun 28, 2011 by Eiko
3

Turns out I needed to delete the application from the iPhone Simulator and load it again. Shouldn't it do this automatically???

answered on Stack Overflow Jun 28, 2011 by DanielGibbs
1

I recommend you do Build/Clean All Targets, delete the /Build/ directory in your project and then re-run the project. If it still crashes, then you must have missed something.

answered on Stack Overflow Jun 28, 2011 by PengOne
0

You have a malformed outlet. The nib is looking for something to tie "password" to, but there is no corresponding property in your controller.

answered on Stack Overflow Jun 28, 2011 by matt
-1

Just get this by: 1) Select the name you want to change: MyProjectNameViewController 2) Edit -> Refactor, fill in to "LoginViewController" That's it. But pay attention if on storyboardID might to be changed manually if you set it same as view controller before.

answered on Stack Overflow Aug 21, 2014 by William Hu

User contributions licensed under CC BY-SA 3.0