0

I have a button with this action:

@IBAction func btnLogin(_ sender: Any) {
    if(userName.text! == "staff" && password.text! == "pass") {
            performSegue(withIdentifier: "showStaffPage", sender: self)
        } else if (userName.text! == "driver" && password.text! == "pass") {
            performSegue(withIdentifier: "showDriverPage", sender: self)
        } else if (userName.text! == "parent" && password.text! == "pass") {
            performSegue(withIdentifier: "showParentPage", sender: self)
        } else {
            errorMsg.alpha = 1;
        }
    }

It works fine for "driver" and for "parent", but it gives the error below for "staff". I have tried cleaning, and I have made sure all names and locations are valid and still exist. Not sure what to try anymore.

2018-05-15 09:22:10.089411-0400 After School Tracker[12989:162055] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/user136086/Library/Developer/CoreSimulator/Devices/EE08864F-5D96-49E7-8E52-AFE0056A6BA2/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-05-15 09:22:10.089849-0400 After School Tracker[12989:162055] [MC] Reading from private effective user settings.
2018-05-15 09:22:20.767770-0400 After School Tracker[12989:162055] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<After_School_Tracker.StaffViewController 0x7fd191f16d80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewHere.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d1811e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010c816031 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010d1810b9 -[NSException raise] + 9
    3   Foundation                          0x000000010c237b47 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
    4   UIKit                               0x000000010d799f20 -[UIViewController setValue:forKey:] + 87
    5   UIKit                               0x000000010da87d56 -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x000000010d123e8d -[NSArray makeObjectsPerformSelector:] + 317
    7   UIKit                               0x000000010da86700 -[UINib instantiateWithOwner:options:] + 1856
    8   UIKit                               0x000000010d7a1137 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
    9   UIKit                               0x000000010d7a1a64 -[UIViewController loadView] + 177
    10  UIKit                               0x000000010d7a1d81 -[UIViewController loadViewIfRequired] + 175
    11  UIKit                               0x000000010d7a25d4 -[UIViewController view] + 27
    12  UIKit                               0x000000010d7d3c6e -[UINavigationController _startCustomTransition:] + 945
    13  UIKit                               0x000000010d7ea5e2 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714
    14  UIKit                               0x000000010d7eb8cc -[UINavigationController __viewWillLayoutSubviews] + 150
    15  UIKit                               0x000000010da43bd7 -[UILayoutContainerView layoutSubviews] + 231
    16  UIKit                               0x000000010d6cd808 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
    17  QuartzCore                          0x0000000113b7561a -[CALayer layoutSublayers] + 177
    18  QuartzCore                          0x0000000113b7982b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
    19  QuartzCore                          0x0000000113b0029f _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
    20  QuartzCore                          0x0000000113b2d940 _ZN2CA11Transaction6commitEv + 568
    21  UIKit                               0x000000010d5f834f _UIApplicationFlushRunLoopCATransactionIfTooLate + 167
    22  UIKit                               0x000000010df5d532 __handleEventQueueInternal + 6875
    23  CoreFoundation                      0x000000010d123bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000010d1084af __CFRunLoopDoSources0 + 271
    25  CoreFoundation                      0x000000010d107a6f __CFRunLoopRun + 1263
    26  CoreFoundation                      0x000000010d10730b CFRunLoopRunSpecific + 635
    27  GraphicsServices                    0x0000000112cfda73 GSEventRunModal + 62
    28  UIKit                               0x000000010d5fe0b7 UIApplicationMain + 159
    29  After School Tracker                0x000000010bef43b7 main + 55
    30  libdyld.dylib                       0x00000001115ec955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
Jacob Ahlberg
  • 2,352
  • 6
  • 22
  • 44
Alex
  • 160
  • 1
  • 2
  • 22

3 Answers3

1

This happens when a Storyboard Scene has a outdated IBOutlet to something that no longer exists. This happens to me all the time when I create an IBOutlet, connect it to something in Interface Builder, and then delete the associated IBOutlet definition in code. Unfortunately, this is only identified as a runtime issue (meaning the compiler won't catch it).

Open StaffViewController in Interface Builder, and open the Connections Inspector and look for an IBOutlet that is still connected, but has been deleted from the associated code file.

Andy Obusek
  • 12,614
  • 4
  • 41
  • 62
  • Thank you for the quick response, I ended up having an extra pointer in storyboard ☹️. This helped, I wish I could up vote it but I don't have enough rep. – Alex May 15 '18 at 13:48
  • you can mark the answer as accepted - you should do that, and it will also grant you rep – Andy Obusek May 15 '18 at 14:05
0
'[<After_School_Tracker.StaffViewController 0x7fd191f16d80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewHere.

This means that an IBOutlet called viewHere is missing from your class. if you add that, I think it will solve the problem

  • Thank you for the quick response, I ended up having an extra pointer in storyboard ☹️. This helped, I wish I could up vote it but I don't have enough rep. – Alex May 15 '18 at 13:48
0

The problem is in destination of

performSegue(withIdentifier: "showStaffPage", sender: self)

which is class StaffViewController , there is a view named viewHere that you removed in class code but still in IB

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • Thank you for the quick response, I ended up having an extra pointer in storyboard ☹️. This helped, I wish I could up vote it but I don't have enough rep. – Alex May 15 '18 at 13:48