Why "Unknown class"? - ios

I am a beginner in programming, and new to Stack Overflow as well. I'm still figuring out how codes and this website work, so I'm sorry if I didn't use them correctly. (I'm not a native English speaker, but I'll do my best to explain my question as well as possible)
I'm using Xcode Version 8.1, and Swift.
I'm building an app for my school project. I've already created To-Do-List App and Countdown Timer App. So, I want to put them together in one app now.
I created a new project and inserted Tab Bar Controller. Then copied all the files I used in To-Do-List and Countdown Timer apps, and set up the storyboard.
There are no caution marks, but when I run the simulator, an error comes up and the simulator stops. The error I got is "Thread 1: signal SIGABRT" in this line in AppDelegate.swift:
class AppDelegate: UIResponder, UIApplicationDelegate {
and the message in the console is:
2017-01-06 20:32:22.207 PP Final App[61701:3259153] Unknown class PomodoroViewController in Interface Builder file.
2017-01-06 20:32:22.713 PP Final App[61701:3259153] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fd7faf075d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lbTimer.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001100c234b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fb2321e objc_exception_throw + 48
2 CoreFoundation 0x00000001100c2299 -[NSException raise] + 9
3 Foundation 0x000000010f63326f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x000000011067f4ef -[UIViewController setValue:forKey:] + 88
5 UIKit 0x00000001108f379e -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000110067590 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x00000001108f2122 -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x0000000110685c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x0000000110686543 -[UIViewController loadView] + 177
10 UIKit 0x0000000110686878 -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x00000001106870cc -[UIViewController view] + 27
12 UIKit 0x00000001106e52df -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 483
13 UIKit 0x00000001106e4721 -[UITabBarController transitionFromViewController:toViewController:] + 59
14 UIKit 0x00000001106e05e2 -[UITabBarController _setSelectedViewController:] + 365
15 UIKit 0x00000001106e0464 -[UITabBarController setSelectedViewController:] + 234
16 UIKit 0x000000011059e6e6 +[UIView(Animation) performWithoutAnimation:] + 90
17 UIKit 0x00000001106daa00 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 354
18 UIKit 0x00000001106dbb7a -[UITabBarController viewWillAppear:] + 206
19 UIKit 0x000000011068ca0f -[UIViewController _setViewAppearState:isAnimating:] + 692
20 UIKit 0x000000011068d11f -[UIViewController __viewWillAppear:] + 147
21 UIKit 0x000000011068e913 -[UIViewController viewWillMoveToWindow:] + 507
22 UIKit 0x0000000110595151 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 621
23 UIKit 0x00000001105a5cf0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 451
24 UIKit 0x00000001105947a1 -[UIView(Hierarchy) addSubview:] + 838
25 UIKit 0x0000000110550f5b -[UIWindow addRootViewControllerViewIfPossible] + 849
26 UIKit 0x00000001105513a2 -[UIWindow _setHidden:forced:] + 293
27 UIKit 0x0000000110564cb5 -[UIWindow makeKeyAndVisible] + 42
28 UIKit 0x00000001104ddc89 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818
29 UIKit 0x00000001104e3de9 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731
30 UIKit 0x00000001104e0f69 -[UIApplication workspaceDidEndTransaction:] + 188
31 FrontBoardServices 0x0000000113ed3723 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
32 FrontBoardServices 0x0000000113ed359c -[FBSSerialQueue _performNext] + 189
33 FrontBoardServices 0x0000000113ed3925 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
34 CoreFoundation 0x0000000110067311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
35 CoreFoundation 0x000000011004c59c __CFRunLoopDoSources0 + 556
36 CoreFoundation 0x000000011004ba86 __CFRunLoopRun + 918
37 CoreFoundation 0x000000011004b494 CFRunLoopRunSpecific + 420
38 UIKit 0x00000001104df7e6 -[UIApplication _run] + 434
39 UIKit 0x00000001104e5964 UIApplicationMain + 159
40 PP Final App 0x000000010f52c1cf main + 111
41 libdyld.dylib 0x000000011373c68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
In this message, I see "Unknown class PomodoroViewController in Interface Builder file." This is the problem, right? But I don't know why I got this message. Are there any problems in the file?
Is the way I use Tab Bar Controller right?
Here's the code file of Pomodoro View Controller:
PomodoroViewController
import UIKit
class PomodoroViewController: UIViewController {
#IBOutlet weak var lbTimer: UILabel!
let pomodoroTime: TimeInterval = 60 * 25 //Pomodoro Timer 25 minutes
let formatter = DateFormatter()
var theTime: TimeInterval = 0.0
override func viewDidLoad(){
super.viewDidLoad()
formatter.dateFormat = "mm:ss"
let startTime = Date(timeIntervalSinceReferenceDate: pomodoroTime)
lbTimer.text = formatter.string(from: startTime)
}
override func didReceiveMemoryWarning(){
super.didReceiveMemoryWarning()
}
#IBAction func countDown(_ sender: UIButton) {
theTime = pomodoroTime
Timer.scheduledTimer(timeInterval: 1.0,
target: self,
selector: #selector(PomodoroViewController.tickTimer(timer:)),
userInfo: nil,
repeats: true)
}
func tickTimer(timer: Timer){
theTime -= 1.0
let newTime = Date(timeIntervalSinceReferenceDate: theTime)
if theTime < 0.1 {
timer.invalidate()
}
}
}
and this is how the storyboard looks like:
storyboard

What this error means is:
You have a storyboard (or maybe a xib) that says that one of the view controllers is a PomodoroViewController. But...
PomodoroViewController does not exist when the app is running.
The message says that iOS tried to find PomodoroViewController but it wasn't there, so it tried to use UIViewController instead. Except UIViewController doesn't have the lbTimer property, which makes the app crash.
There are a couple of reasons this could happen:
You might have forgotten to copy PomodoroViewController to the new project.
If you did copy it, you might not be including it in the app target. [Files can be included in the Xcode project that don't get compiled, because you might use the same project file for more than one target.]
In the second case, make sure that the file is checked in the file inspector on the right side of the Xcode window:

Related

How to move from one viewcontroller to another in a storyboard using swift [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 4 years ago.
I am trying to move from SignInViewController to RegisterUserViewController on button click .Here is code
#IBAction func RegisterNewAccountButtonTapped(_ sender: Any) {
print("Register account button tapped")
//RegisterUserViewController
// let storyboard = UIStoryboard(name: "SignInViewController", bundle: nil)
let vc = self.storyboard?.instantiateViewController(withIdentifier: "RegisterUserViewController") as! RegisterUserViewController
self.present(vc, animated: true)
}
Here in this picture are the class and storyboard id
Here is error that is coming on pressing Register New Account button .
2018-04-27 06:09:24.720143-0700 UserRegistrationExample[10193:1788611] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UserRegistrationExample.RegisterUserViewController 0x7f84b4f171b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key repeatPasswordTextField.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010db1826b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010a1fbf41 objc_exception_throw + 48
2 CoreFoundation 0x000000010db181b9 -[NSException raise] + 9
3 Foundation 0x0000000109c20883 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x000000010a95dd56 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x000000010ac3ac94 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010dabb61d -[NSArray makeObjectsPerformSelector:] + 317
7 UIKit 0x000000010ac3964a -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x000000010a964d49 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
9 UIKit 0x000000010a965652 -[UIViewController loadView] + 177
10 UIKit 0x000000010a965983 -[UIViewController loadViewIfRequired] + 195
11 UIKit 0x000000010a9661e0 -[UIViewController view] + 27
12 UIKit 0x000000010b3bd39d -[_UIFullscreenPresentationController _setPresentedViewController:] + 89
13 UIKit 0x000000010a936a8f -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
14 UIKit 0x000000010a979338 -[UIViewController _presentViewController:withAnimationController:completion:] + 3808
15 UIKit 0x000000010a97c14a __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 134
16 UIKit 0x000000010a97c5ea -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
17 UIKit 0x000000010a97c086 -[UIViewController presentViewController:animated:completion:] + 181
18 UserRegistrationExample 0x00000001098e0ae5 _T023UserRegistrationExample20SignInViewControllerC30RegisterNewAccountButtonTappedyypF + 1077
19 UserRegistrationExample 0x00000001098e0c58 _T023UserRegistrationExample20SignInViewControllerC30RegisterNewAccountButtonTappedyypFTo + 72
20 UIKit 0x000000010a7cd631 -[UIApplication sendAction:to:from:forEvent:] + 83
21 UIKit 0x000000010a942000 -[UIControl sendAction:to:forEvent:] + 67
22 UIKit 0x000000010a94231d -[UIControl _sendActionsForEvents:withEvent:] + 450
23 UIKit 0x000000010a94124a -[UIControl touchesEnded:withEvent:] + 618
24 UIKit 0x000000010a840bf1 -[UIWindow _sendTouchesForEvent:] + 2807
25 UIKit 0x000000010a842314 -[UIWindow sendEvent:] + 4124
26 UIKit 0x000000010a7e82da -[UIApplication sendEvent:] + 352
27 UIKit 0x000000010b0f6f18 __dispatchPreprocessedEventFromEventQueue + 2809
28 UIKit 0x000000010b0f9a7f __handleEventQueueInternal + 5957
29 CoreFoundation 0x000000010dabb351 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
30 CoreFoundation 0x000000010db5ad71 __CFRunLoopDoSource0 + 81
31 CoreFoundation 0x000000010da9fcb9 __CFRunLoopDoSources0 + 185
32 CoreFoundation 0x000000010da9f29f __CFRunLoopRun + 1279
33 CoreFoundation 0x000000010da9eb29 CFRunLoopRunSpecific + 409
34 GraphicsServices 0x00000001101af9c6 GSEventRunModal + 62
35 UIKit 0x000000010a7cb9a4 UIApplicationMain + 159
36 UserRegistrationExample 0x00000001098deee7 main + 55
37 libdyld.dylib 0x000000010ec3a621 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have visited the following links but non of them solved the problem
https://coderwall.com/p/cjuzng/swift-instantiate-a-view-controller-using-its-storyboard-name-in-xcode
instantiateViewControllerWithIdentifier - Storyboard id set but still not working
Present View Controller in Storyboard with a Navigation Controller - Swift
Swift 3, Xcode 8 Instantiate View Controller is not working
Instantiate and Present a viewController in Swift
How to remove this error.
You can download the code from this link
.https://drive.google.com/open?id=1yUaKeI6ZQphN7CsoiaeF2p4TmW_B5-9u
Try CTRL and drag from your button to the next ViewController. Then select "show". This is how you set a segue. Then click on the segue and give him an identifier. Then you need to set the
performSegue(withIdentifier: String, sender: self)
Have you tried this?

Eureka MultivaluedSection Add NSRangeException

Any kind of special setup needed to make MultivaluedSection Add functionality to work in Eureka?
I have copied code from Example project into mine and instead of rows being added I get an exception. Funny thing is that in Example project everything seems to work fine, that makes me thinking that I need some kind of additional setup, maybe?
Exception:
'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]: row (1) beyond bounds (1) for section (1).
uncaught exception 'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:]: row (1) beyond bounds (1) for section (1).'
*** First throw call stack:
(
0 CoreFoundation 0x000000010c9ab1cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010c30df41 objc_exception_throw + 48
2 CoreFoundation 0x000000010ca1fb95 +[NSException raise:format:] + 197
3 UIKit 0x0000000109bc8d76 -[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:usingPresentationValues:] + 1861
4 UIKit 0x0000000109bc9b8f -[UITableView _scrollToRowAtIndexPath:atScrollPosition:animated:usingPresentationValues:] + 146
5 UIKit 0x0000000109bc9a11 -[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:] + 123
6 Eureka 0x0000000107b7558c _T06Eureka18FormViewControllerC05tableC0ySo07UITableC0C_SC0fC16CellEditingStyleO6commit10Foundation9IndexPathV8forRowAttF + 2780
7 Eureka 0x0000000107b75ba7 _T06Eureka18FormViewControllerC05tableC0ySo07UITableC0C_SC0fC16CellEditingStyleO6commit10Foundation9IndexPathV8forRowAttFTo + 119
8 UIKit 0x0000000109bee33e -[UITableView _didInsertRowForTableCell:] + 122
9 UIKit 0x0000000109ec6bee -[UITableViewCell editControlWasClicked:] + 180
10 UIKit 0x0000000109a949bd -[UIApplication sendAction:to:from:forEvent:] + 83
11 UIKit 0x0000000109c0b183 -[UIControl sendAction:to:forEvent:] + 67
12 UIKit 0x0000000109c0b4a0 -[UIControl _sendActionsForEvents:withEvent:] + 450
13 UIKit 0x0000000109c0b614 -[UIControl _sendActionsForEvents:withEvent:] + 822
14 UIKit 0x0000000109c0a3cd -[UIControl touchesEnded:withEvent:] + 618
15 UIKit 0x000000010a071a88 _UIGestureEnvironmentSortAndSendDelayedTouches + 5560
16 UIKit 0x000000010a06b93e _UIGestureEnvironmentUpdate + 1483
17 UIKit 0x000000010a06b327 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
18 UIKit 0x000000010a06a3d3 -[UIGestureEnvironment _updateGesturesForEvent:window:] + 288
19 UIKit 0x0000000109b0a45c -[UIWindow sendEvent:] + 4102
20 UIKit 0x0000000109aaf802 -[UIApplication sendEvent:] + 352
21 UIKit 0x000000010a3e1a50 __dispatchPreprocessedEventFromEventQueue + 2809
22 UIKit 0x000000010a3e45b7 __handleEventQueueInternal + 5957
23 CoreFoundation 0x000000010c94e2b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x000000010c9edd31 __CFRunLoopDoSource0 + 81
25 CoreFoundation 0x000000010c932c19 __CFRunLoopDoSources0 + 185
26 CoreFoundation 0x000000010c9321ff __CFRunLoopRun + 1279
27 CoreFoundation 0x000000010c931a89 CFRunLoopRunSpecific + 409
28 GraphicsServices 0x0000000110c5a9c6 GSEventRunModal + 62
29 UIKit 0x0000000109a92d30 UIApplicationMain + 159
Solved.
My custom ViewController was overriding override func viewWillAppear(_ animated: Bool), but I forgot to call super.viewWillAppear().
Turns out that was critical for Eureka to work properly
Related to OP, I too had same error. In my case it was caused because I was embedding the FormViewController() incorrectly inside another view controller.
My solution was to add it as childViewController (see Eureka Issue 1045). In short, childViewControllers receive appearance & rotation events from parent VC (viewWillAppear etc) What does addChildViewController actually do?.
My working Sample code (swift 4.2):
class MyViewController: UIViewController {
var tempForm:FormViewController!
override func viewDidLoad() {
super.viewDidLoad()
tempTemp = FormViewController()
self.addChild(tempForm)
self.setupTempFormSections()
}
private func setupTempFormSections(){
tempForm.form +++ Section(...)
}
...
}

My app won't run... because of an unchanged AppDelegate?

My app was working perfectly until I added an #IBAction. Now I just get this error:
2017-06-09 07:55:35.285 Press[1594:102051] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key add.'
* First throw call stack:
(
0 CoreFoundation 0x000000010724bb0b exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001044f3141 objc_exception_throw + 48
2 CoreFoundation 0x000000010724ba59 -[NSException raise] + 9
3 Foundation 0x0000000104008e8b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKit 0x0000000104b60644 -[UIViewController setValue:forKey:] + 87
5 UIKit 0x0000000104dcd6b9 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001071f1e8d -[NSArray makeObjectsPerformSelector:] + 269
7 UIKit 0x0000000104dcc06f -[UINib instantiateWithOwner:options:] + 1856
8 UIKit 0x0000000104b66c73 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000104b67589 -[UIViewController loadView] + 177
10 UIKit 0x0000000104b678ba -[UIViewController loadViewIfRequired] + 195
11 UIKit 0x0000000104b6810a -[UIViewController view] + 27
12 UIKit 0x0000000104a3063a -[UIWindow addRootViewControllerViewIfPossible] + 65
13 UIKit 0x0000000104a30d20 -[UIWindow _setHidden:forced:] + 294
14 UIKit 0x0000000104a43b6e -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x00000001049bd31f -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4346
16 UIKit 0x00000001049c3584 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1709
17 UIKit 0x00000001049c0793 -[UIApplication workspaceDidEndTransaction:] + 182
18 FrontBoardServices 0x000000010895b5f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24
19 FrontBoardServices 0x000000010895b46d -[FBSSerialQueue _performNext] + 186
20 FrontBoardServices 0x000000010895b7f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x00000001071f1c01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
22 CoreFoundation 0x00000001071d70cf __CFRunLoopDoSources0 + 527
23 CoreFoundation 0x00000001071d65ff __CFRunLoopRun + 911
24 CoreFoundation 0x00000001071d6016 CFRunLoopRunSpecific + 406
25 UIKit 0x00000001049bf02f -[UIApplication _run] + 468
26 UIKit 0x00000001049c50d4 UIApplicationMain + 159
27 Press 0x0000000103f1a877 main + 55
28 libdyld.dylib 0x00000001081eb65d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
This is my Viewcontroller code:
import UIKit
class ViewController: UIViewController {
// OUTLETS
#IBOutlet weak var score: UILabel!
#IBAction func add(_ sender: Any) {
add()
}
// VARIABLES
var scoreVar = 0
let levelUpAt = [50, 100, 500, 1000, 5000, 10000, 50000, 100000]
var currentLevel = 1
var toAdd = 1
// OVERRIDES
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
// FUNCTIONS
// Below code adds to the score
func add() {
scoreVar += 1 // Adds 1 to scoreVar
score.text = "scoreVar"; // Updates text to match
checkForLevelUp(); // Calls the function defined in the next few days ago
}
// Below code checks if the score meets the next level requirements
func checkForLevelUp() {
if (scoreVar - 1 < levelUpAt[currentLevel - 1]) { // Complicated math-y if statment
currentLevel += 1
toAdd += 1
}
}
}
It seems to be stuck on the class AppDelegate: UIResponder, UIApplicationDelegate { line on the AppDelegate, according to the debugger.
Go to your story board and click on the ViewController. Click one the Add button you created.
On the right side in the Outlet Inspector, remove anything mentioning the "Add" button.
Finally, recreate the outlets by option dragging from the button to your view controller and setting the type to "Action".

Swift NSUnknownKeyException FoodTracker

I'm just beginning to learn swift, and I have trouble understanding what the console is trying to tell me with this error. I'm following the Apple's guide to learn swift and in the section "Connect the UI to Code" I'm having the following problem:
2016-02-22 01:06:54.121 FoodTracker[20300:502503] <CATransformLayer: 0x7fab3973cb90> - changing property contentsCenter in transform-only layer, will have no effect
2016-02-22 01:06:54.127 FoodTracker[20300:502503] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FoodTracker.ViewController 0x7fab394a9a00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key setDefaultLabelText.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001040b7e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000105df7deb objc_exception_throw + 48
2 CoreFoundation 0x00000001040b7aa9 -[NSException raise] + 9
3 Foundation 0x00000001044809bb -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000104a63320 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x0000000104c91f41 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x0000000103ff84a0 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x0000000104c90924 -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000104a69eea -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000104a6a816 -[UIViewController loadView] + 178
10 UIKit 0x0000000104a6ab74 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000104a6b2e7 -[UIViewController view] + 27
12 UIKit 0x0000000104941ab0 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x0000000104942199 -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000104953c2e -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x00000001048cc663 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x00000001048d2cc6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
17 UIKit 0x00000001048cfe7b -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x0000000107c8c754 -[FBSSerialQueue _performNext] + 192
19 FrontBoardServices 0x0000000107c8cac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
20 CoreFoundation 0x0000000103fe3a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
21 CoreFoundation 0x0000000103fd995c __CFRunLoopDoSources0 + 556
22 CoreFoundation 0x0000000103fd8e13 __CFRunLoopRun + 867
23 CoreFoundation 0x0000000103fd8828 CFRunLoopRunSpecific + 488
24 UIKit 0x00000001048cf7cd -[UIApplication _run] + 402
25 UIKit 0x00000001048d4610 UIApplicationMain + 171
26 FoodTracker 0x0000000103ed947d main + 109
27 libdyld.dylib 0x000000010690092d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Also, this is the code I'm running:
import UIKit
class ViewController: UIViewController {
//MARK: Propierties
#IBOutlet weak var nameTextField: UITextField!
#IBOutlet weak var mealNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
//MARK: Actions
#IBAction func setDefaultLabelText(sender: UIButton) {
mealNameLabel.text = "Default Text"
}
}
Thank you in advance for your help. Looking forward to it.
Already solved my problem. As I was just starting to code, I tried copying and pasting what I've written into a new file and it works perfectly now. No issues at all. It might have been some bug with the config. Thanks anyway.

App crashes when i try to run this page

My app builds and runs successfully and the other pages do not have any issues. This page builds successfully, however, when I attempt to go to the page the app will crash. I am unsure of how to fix this issue.
import UIKit
class ViewController: UIViewController
{
#IBOutlet weak var txtView: UITextView!
func loadData (){
var txtView: NSMutableArray = NSMutableArray ()
txtView.removeAllObjects()
var query = PFQuery(className:"NewsPages")
query.getObjectInBackgroundWithId("KerL5Xf0Bx")
{
(NewsPages: PFObject!, error: NSError!) -> Void in
if error == nil
{
let content = NewsPages["content"] as String
self.txtView.text = String()
}
else
{
NSLog("%#", error)
}
}
}
}
My Error Code:
2014-12-21 20:00:05.679 App[1707:84302] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<App.ViewController 0x7fab1a4aabf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key GameScore.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b649f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d18dbb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010b649b79 -[NSException raise] + 9
3 Foundation 0x000000010ba617b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010b593e80 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010c19ac7d -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010bff9f98 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x000000010bffa588 -[UIViewController loadView] + 109
8 UIKit 0x000000010bffa7f9 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x000000010bffac8e -[UIViewController view] + 27
10 UIKit 0x000000010c59c41e -[_UIFullscreenPresentationController _setPresentedViewController:] + 65
11 UIKit 0x000000010bfd6429 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 105
12 UIKit 0x000000010c006a41 -[UIViewController _presentViewController:withAnimationController:completion:] + 1746
13 UIKit 0x000000010c008d81 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
14 UIKit 0x000000010c008ca5 -[UIViewController presentViewController:animated:completion:] + 229
15 UIKit 0x000000010bed68be -[UIApplication sendAction:to:from:forEvent:] + 75
16 UIKit 0x000000010bfdd410 -[UIControl _sendActionsForEvents:withEvent:] + 467
17 UIKit 0x000000010bfdc7df -[UIControl touchesEnded:withEvent:] + 522
18 UIKit 0x000000010bf1c308 -[UIWindow _sendTouchesForEvent:] + 735
19 UIKit 0x000000010bf1cc33 -[UIWindow sendEvent:] + 683
20 UIKit 0x000000010bee99b1 -[UIApplication sendEvent:] + 246
21 UIKit 0x000000010bef6a7d _UIApplicationHandleEventFromQueueEvent + 17370
22 UIKit 0x000000010bed2103 _UIApplicationHandleEventQueue + 1961
23 CoreFoundation 0x000000010b57f551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x000000010b57541d __CFRunLoopDoSources0 + 269
25 CoreFoundation 0x000000010b574a54 __CFRunLoopRun + 868
26 CoreFoundation 0x000000010b574486 CFRunLoopRunSpecific + 470
27 GraphicsServices 0x000000010e6e09f0 GSEventRunModal + 161
28 UIKit 0x000000010bed5420 UIApplicationMain + 1282
29 Mars App 0x000000010a21d98e top_level_code + 78
30 Mars App 0x000000010a21da6a main + 42
31 libdyld.dylib 0x000000010e1f0145 start + 1
32 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Open your corresponding xib file check all UI outlet connections, there you can see warning in some connection . delete that.
This error is always your xib file bind a error or not exists method ,so when you load view controllers fail.Check your xib file

Resources