How to assign current checked String to detailLabel UITableViewCell? - ios

override func viewDidLoad() {
super.viewDidLoad()
**detailLabel.text = game**
}
#IBAction func selectedGame(segue:UIStoryboardSegue) {
if let gamePickerViewController = segue.sourceViewController as? GamePickerViewController,
selectedGame = gamePickerViewController.selectedGame {
**detailLabel.text = selectedGame**
game = selectedGame
}
}
Swift Compile Error 'text' is unavailable: APIs deprecated as of iOS 7 and earlier are unavailable in Swift
Edit :
#IBOutlet weak var detailLabel: UILabel!
But,
init PlayerDetailsViewController
2015-09-01 14:14:45.050 Ratings[3594:145699] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Ratings.PlayerDetailsViewController 0x7ff6c3d42e80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key detailLabelCurrent.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010483dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001063a8bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010483d8a9 -[NSException raise] + 9
3 Foundation 0x0000000104c5bb53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000104785d50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x00000001053b44eb -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x000000010520c6d8 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x000000010520ccc8 -[UIViewController loadView] + 109
8 UIKit 0x00000001053d0db8 -[UITableViewController loadView] + 76
9 UIKit 0x000000010520cf39 -[UIViewController loadViewIfRequired] + 75
10 UIKit 0x000000010520d3ce -[UIViewController view] + 27
11 UIKit 0x0000000105246d3b -[UINavigationController preferredContentSize] + 149
12 UIKit 0x00000001051eceee -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 101
13 UIKit 0x00000001051ea33d __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 122
14 UIKit 0x00000001051005ec _applyBlockToCFArrayCopiedToStack + 314
15 UIKit 0x0000000105100466 _afterCACommitHandler + 533
16 CoreFoundation 0x0000000104770ca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
17 CoreFoundation 0x0000000104770c00 __CFRunLoopDoObservers + 368
18 CoreFoundation 0x0000000104766a33 __CFRunLoopRun + 1123
19 CoreFoundation 0x0000000104766366 CFRunLoopRunSpecific + 470
20 GraphicsServices 0x0000000108811a3e GSEventRunModal + 161
21 UIKit 0x00000001050dc8c0 UIApplicationMain + 1282
22 Ratings 0x000000010461b357 main + 135
23 libdyld.dylib 0x0000000106ade145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I have encountered with these situation, how can i fix these lines to prove all of iOS versions?

Related

libc++abi.dylib: terminating with uncaught exception of type NSException - Xcode 8

I'm working with the storyboard and swift 3 on xCode 8 and I get the following error:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
here is the complete error log:
2016-11-03 17:49:13.614 SidebarMenu[14577:867114] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SidebarMenu.PopOverViewController 0x7fe4aa0401c0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btn3_leftTapped.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010beda34b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010b93b21e objc_exception_throw + 48
2 CoreFoundation 0x000000010beda299 -[NSException raise] + 9
3 Foundation 0x000000010b44b2ff -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
4 UIKit 0x000000010cba78c3 -[UIViewController setValue:forKey:] + 88
5 UIKit 0x000000010ce1bbe6 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x000000010be7f590 -[NSArray makeObjectsPerformSelector:] + 256
7 UIKit 0x000000010ce1a56a -[UINib instantiateWithOwner:options:] + 1867
8 UIKit 0x000000010cbadff5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
9 UIKit 0x000000010cbae917 -[UIViewController loadView] + 177
10 UIKit 0x000000010cbaec4c -[UIViewController loadViewIfRequired] + 201
11 UIKit 0x000000010cbaf4a0 -[UIViewController view] + 27
12 UIKit 0x000000010cbfd3ba -[UINavigationController preferredContentSize] + 198
13 UIKit 0x000000010d4ff0a1 -[UIPopoverPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 152
14 UIKit 0x000000010cb8d5bc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 111
15 UIKit 0x000000010ca1a8bb _runAfterCACommitDeferredBlocks + 320
16 UIKit 0x000000010ca0753f _cleanUpAfterCAFlushAndRunDeferredBlocks + 566
17 UIKit 0x000000010ca387ce _afterCACommitHandler + 176
18 CoreFoundation 0x000000010be7ee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
19 CoreFoundation 0x000000010be7ed87 __CFRunLoopDoObservers + 391
20 CoreFoundation 0x000000010be63b9e __CFRunLoopRun + 1198
21 CoreFoundation 0x000000010be63494 CFRunLoopRunSpecific + 420
22 GraphicsServices 0x00000001115b2a6f GSEventRunModal + 161
23 UIKit 0x000000010ca0df34 UIApplicationMain + 159
24 SidebarMenu 0x000000010af53b5f main + 111
25 libdyld.dylib 0x0000000112e2968d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
The first line of the error message tells me that the error is in the PopOverViewController and than in btn3_leftTapped.
In the PopOverViewController I have connected an Action from the button:
#IBAction func btn3_leftTappedNow(_ sender: AnyObject) {
}
#IBAction func btn3_rightTapped(_ sender: AnyObject) {
self.dismiss(animated: true){ () -> Void in
NotificationCenter.default.post(name: NSNotification.Name(rawValue: btn3_rightTappedDone), object: nil, userInfo: nil)
}
}
First I thought that i have to delete this connection and then recreate it, but it does not change. Even if I delete the connection and create a new one with a different name like btn3_leftTappedNow I still get the error message shown above.
I used ctrl + f to search in my .swift file after the phrase but it isn't in my document any more.
I tried Product -> Clean but I still get the error and I have no problem building the app.
What can I do to solve this error?

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.

Swift 2 arc4random_uniform crash?

I have a very simple execution, but it's crashing for some reason. Any ideas why?
import UIKit
class ViewController: UIViewController {
#IBOutlet var myTextField: UITextField!
#IBOutlet var resultsLabel: UILabel!
#IBAction func pressButton(sender: AnyObject) {
let diceRoll = String(arc4random_uniform(UInt32(6)))
print(diceRoll)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
Crash Log added
2016-02-06 16:24:32.358 GuessingGame[6330:496415] * Terminating app
due to uncaught exception 'NSUnknownKeyException', reason: '[
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key TextField.' * First throw call stack: ( 0
CoreFoundation 0x000000010960ae65 exceptionPreprocess + 165 1
libobjc.A.dylib 0x000000010b34adeb objc_exception_throw + 48 2
CoreFoundation 0x000000010960aaa9 -[NSException raise] + 9 3
Foundation 0x00000001099d39bb -[NSObject(NSKeyValueCoding)
setValue:forKey:] + 288 4 UIKit 0x0000000109fb6320 -[UIViewController
setValue:forKey:] + 88 5 UIKit 0x000000010a1e4f41
-[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x000000010954b4a0 -[NSArray makeObjectsPerformSelector:] + 224 7
UIKit 0x000000010a1e3924 -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x0000000109fbceea -[UIViewController
_loadViewFromNibNamed:bundle:] + 381 9 UIKit 0x0000000109fbd816 -[UIViewController loadView] + 178 10 UIKit 0x0000000109fbdb74 -[UIViewController loadViewIfRequired] + 138 11 UIKit 0x0000000109fbe2e7 -[UIViewController view] + 27 12 UIKit
0x0000000109e94ab0 -[UIWindow addRootViewControllerViewIfPossible] +
61 13 UIKit 0x0000000109e95199 -[UIWindow _setHidden:forced:] + 282 14
UIKit 0x0000000109ea6c2e -[UIWindow makeKeyAndVisible] + 42 15 UIKit
0x0000000109e1f663 -[UIApplication
_callInitializationDelegatesForMainScene:transitionContext:] + 4131 16 UIKit 0x0000000109e25cc6 -[UIApplication
_runWithMainScene:transitionContext:completion:] + 1760 17 UIKit 0x0000000109e22e7b -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x000000010d1df754 -[FBSSerialQueue
_performNext] + 192 19 FrontBoardServices 0x000000010d1dfac2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45 20 CoreFoundation 0x0000000109536a31
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 21 CoreFoundation 0x000000010952c95c __CFRunLoopDoSources0 + 556 22
CoreFoundation 0x000000010952be13 __CFRunLoopRun + 867 23
CoreFoundation 0x000000010952b828 CFRunLoopRunSpecific + 488 24 UIKit
0x0000000109e227cd -[UIApplication _run] + 402 25 UIKit
0x0000000109e27610 UIApplicationMain + 171 26 GuessingGame
0x000000010942b4dd main + 109 27 libdyld.dylib 0x000000010be5392d
start + 1 ) libc++abi.dylib: terminating with uncaught exception of
type NSException (lldb)
Most likely cause is that you renamed your IBOutlet from TextField to myTextField in your code (or added a new link but did not remove the old reference from the control in IB).

Swift: Terminating with uncaught exception of type NSException

I'm developing a simple app and when I click to sign up the user, the app gets terminated. Please help me figure this out.
It says that:
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key CreditCardTextField.'
Here's the error in more detail:
015-06-04 22:42:57.661 ParseStarterProject[43853:4461316] Unknown
class RegisterPageViewController in Interface Builder file. 2015-06-04
22:42:57.712 ParseStarterProject[43853:4461316] * Terminating app
due to uncaught exception 'NSUnknownKeyException', reason:
'[ setValue:forUndefinedKey:]: this
class is not key value coding-compliant for the key
CreditCardTextField.'
* First throw call stack: ( 0 CoreFoundation 0x00000001106ccf35 exceptionPreprocess + 165 1 libobjc.A.dylib
0x000000011233ebb7 objc_exception_throw + 45 2 CoreFoundation
0x00000001106ccb79 -[NSException raise] + 9 3 Foundation
0x0000000110b6b7b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] +
259 4 CoreFoundation 0x0000000110616e80
-[NSArray makeObjectsPerformSelector:] + 224 5 UIKit 0x000000011134bc7d -[UINib instantiateWithOwner:options:] + 1506 6
UIKit 0x00000001111aaf98
-[UIViewController _loadViewFromNibNamed:bundle:] + 242 7 UIKit 0x00000001111ab588 -[UIViewController loadView] + 109 8 UIKit
0x00000001111ab7f9 -[UIViewController loadViewIfRequired] + 75 9
UIKit 0x00000001111abc8e
-[UIViewController view] + 27 10 UIKit 0x000000011174d41e -[_UIFullscreenPresentationController
_setPresentedViewController:] + 65 11 UIKit 0x0000000111187429 -[UIPresentationController
initWithPresentedViewController:presentingViewController:] + 105 12
UIKit 0x00000001111b7a41
-[UIViewController _presentViewController:withAnimationController:completion:] + 1746 13 UIKit 0x00000001111b9d81
__62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132 14
UIKit 0x00000001111b9ca5
-[UIViewController presentViewController:animated:completion:] + 229 15 UIKit 0x00000001110878be
-[UIApplication sendAction:to:from:forEvent:] + 75 16 UIKit 0x000000011118e410 -[UIControl _sendActionsForEvents:withEvent:] + 467
17 UIKit 0x000000011118d7df
-[UIControl touchesEnded:withEvent:] + 522 18 UIKit 0x00000001110cd308 -[UIWindow _sendTouchesForEvent:] + 735 19 UIKit
0x00000001110cdc33 -[UIWindow sendEvent:] + 683 20 UIKit
0x000000011109a9b1 -[UIApplication sendEvent:] + 246 21 UIKit
0x00000001110a7a7d _UIApplicationHandleEventFromQueueEvent + 17370 22
UIKit 0x0000000111083103
_UIApplicationHandleEventQueue + 1961 23 CoreFoundation 0x0000000110602551
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 24 CoreFoundation 0x00000001105f841d
__CFRunLoopDoSources0 + 269 25 CoreFoundation 0x00000001105f7a54 __CFRunLoopRun + 868 26 CoreFoundation
0x00000001105f7486 CFRunLoopRunSpecific + 470 27 GraphicsServices
0x0000000113de79f0 GSEventRunModal + 161 28 UIKit
0x0000000111086420 UIApplicationMain + 1282 29 ParseStarterProject
0x000000010fbbe9de top_level_code + 78 30 ParseStarterProject
0x000000010fbbeaba main + 42 31 libdyld.dylib
0x0000000112b54145 start + 1 32 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException (lldb)
It seems that you have a bronken #IBOutlet for CreditCardTextField, check in your storyboard, as soon as you reconnect the outlet it all should work again
setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key CreditCardTextField.'
This is how you check your outlets:
Select the field, the outlets in the right should be connect correctly and the circles in the code should have a dot inside, if not the connection is broken, control drag to fix it.
NB. this can also happen in a Core Data app if the case of the property in the app code doesn't match a property in the momd. eg "launchPad" vs "launchpad"

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