uchicago-mobi / 2016-Summer-Forum

4 stars 1 forks source link

Error when running simulator #12

Closed pikashoes closed 8 years ago

pikashoes commented 8 years ago

Does anyone else get this error?

" 2016-06-26 12:18:09.701 FoodTracker[9959:598461] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FoodTracker.ViewController 0x7f8379536610> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setDefaultLabelText.' * First throw call stack: ( 0 CoreFoundation 0x00000001083ecd85 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010a190deb objc_exception_throw + 48 2 CoreFoundation 0x00000001083ec9c9 -[NSException raise] + 9 3 Foundation 0x00000001087be19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288 4 UIKit 0x0000000108da7d0c -[UIViewController setValue:forKey:] + 88 5 UIKit 0x0000000108fde7fb -[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x0000000108326890 -[NSArray makeObjectsPerformSelector:] + 224 7 UIKit 0x0000000108fdd1de -[UINib instantiateWithOwner:options:] + 1864 8 UIKit 0x0000000108dae8d6 -[UIViewController _loadViewFromNibNamed:bundle:] + 381 9 UIKit 0x0000000108daf202 -[UIViewController loadView] + 178 10 UIKit 0x0000000108daf560 -[UIViewController loadViewIfRequired] + 138 11 UIKit 0x0000000108dafcd3 -[UIViewController view] + 27 12 UIKit 0x0000000108c85fb4 -[UIWindow addRootViewControllerViewIfPossible] + 61 13 UIKit 0x0000000108c8669d -[UIWindow _setHidden:forced:] + 282 14 UIKit 0x0000000108c98180 -[UIWindow makeKeyAndVisible] + 42 15 UIKit 0x0000000108c0ced9 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131 16 UIKit 0x0000000108c13568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769 17 UIKit 0x0000000108c10714 -[UIApplication workspaceDidEndTransaction:] + 188 18 FrontBoardServices 0x000000010c0218c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24 19 FrontBoardServices 0x000000010c021741 -[FBSSerialQueue _performNext] + 178 20 FrontBoardServices 0x000000010c021aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45 21 CoreFoundation 0x0000000108312301 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 22 CoreFoundation 0x000000010830822c CFRunLoopDoSources0 + 556 23 CoreFoundation 0x00000001083076e3 CFRunLoopRun + 867 24 CoreFoundation 0x00000001083070f8 CFRunLoopRunSpecific + 488 25 UIKit 0x0000000108c0ff21 -[UIApplication _run] + 402 26 UIKit 0x0000000108c14f09 UIApplicationMain + 171 27 FoodTracker 0x00000001082072a2 main + 114 28 libdyld.dylib 0x000000010ac5492d start + 1 29 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException "

I followed the tutorial but can't run the simulator.

kbsrunschi commented 8 years ago

Looks like your variable 'setDefaultLabelText' is set up incorrectly. Check the code to make sure it is initialized properly.

susanstevens commented 8 years ago

That error is usually sign that something isn't wired up correctly between storyboard and your .swift files. Select your "Set Default Text Label" button in storyboard and open up Utilities (the right-hand panel). Then open the Connections Inspector (the right-most button, shaped like an arrow) and check that you have just one connection under "Send Events." If you have an extra connection, you can delete it by tapping on the x.

tabinks commented 8 years ago

See #5 for screenshot of incorrectly wired outlet.

pikashoes commented 8 years ago

I went through and checked all the outlets, and redid some of the parts too just in case. I couldn't get it to work (it still builds, though). So I downloaded the file from the tutorial and compared to see what was different, and ensured that it was the same. The difference is that when I go to LaunchScreen.storyboard, it does not show anything for my file (no preview, no "Food Tracker" title) but in the demo it does.

I'm not sure what could be wrong since now I do not get any error, but instead it highlights the "main" in orange for the code and shows a blank screen in the actual simulator.

tabinks commented 8 years ago

We can look at it tonight.