Thread 1: Sigabrt Help

error

#1

I keep getting the "Thread 1: Sigabrt Error", and I still can't find a fix.

Code:

import UIKit

class ViewController: UIViewController {

var activePlayer = 1 //Grenade launcher
var grenadeScore = 0 //Scoreboard of Grenade Player
var rocketScore = 0 //Scoreboard of Rocket Player
var gameState = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]


let winningCombinations = [[0, 1, 2 ], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6], ]
var gameIsActive = true

@IBOutlet weak var label: UILabel!

@IBOutlet weak var score: UILabel!


@IBAction func action(_ sender: AnyObject)
{
    if (gameState[sender.tag-1] == 0 && gameIsActive == true)
    {
        gameState[sender.tag-1] = activePlayer //Can't override other player's choice
        if (activePlayer == 1) //Player #1
        {
            (sender as AnyObject).setImage(UIImage(named: "Grenade_launcher_icon.png"), for: UIControl.State())
            activePlayer = 2 //Switch to Player #2
        }
        else //Player #2
        {
            (sender as AnyObject).setImage(UIImage(named: "Rocket_launcher_icon.png"), for: UIControl.State())
            activePlayer = 1 //Switch to Player #1
    }
}
    for combination in winningCombinations
    {
        if gameState[combination[0]] != 0 && gameState[combination[0]] == gameState[combination[1]] && gameState[combination[1]] == gameState[combination[2]] // 1st element = 2nd element = 3rd element = WINNER
        {
            gameIsActive = false
            
            if gameState[combination[0]] == 1
            {
                //Grenade won
                label.text = "Victory Royale: Grenade Launcher!" //Prints win message for Grenade Launcher
                grenadeScore += 100
            
                
            }
            else if gameState[combination[0]] == 1{
            }
            
            else
            {
                //Rocket has won
                label.text = "Victory Royale: Rocket Launcher!" //Prints win message for Grenade Launcher
                rocketScore += 100
                
            }
            
            playAgainButton.isHidden = false
            label.isHidden = false
            
        }
        score.text = "P1(G): \(grenadeScore) P2(R): \(rocketScore)"
    }
    gameIsActive = false
    
    for i in gameState
    {
        if i == 1
        {
            gameIsActive = true
            break
        }
    }
    
    if gameIsActive == false
    {
        label.text = "DRAW"
        label.isHidden = false
        playAgainButton.isHidden = false
    }
}


@IBOutlet weak var playAgainButton: UIButton!
@IBAction func playAgain (_ sender: Any) {
    gameState = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    gameIsActive = true
    activePlayer = 1
    label.isHidden = true
    playAgainButton.isHidden = true
    
    for i in  1...9{
        let button = view.viewWithTag(i) as! UIButton
        button.setImage(nil, for: UIControl.State())
    }
}

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

}

Debug:

2018-09-29 22:52:21.305893-0500 Swift TTT[3334:215298] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
2018-09-29 22:52:21.416612-0500 Swift TTT[3334:215298] [framework] CUIThemeStore: No theme registered with id=0
2018-09-29 22:52:21.456694-0500 Swift TTT[3334:215298] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Swift_TTT.ViewController 0x7fa606c0e9e0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key boogie.'
*** First throw call stack:
(
0 CoreFoundation 0x00000001045f829b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000102bd4735 objc_exception_throw + 48
2 CoreFoundation 0x00000001045f7e09 -[NSException raise] + 9
3 Foundation 0x00000001026010b4 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
4 UIKitCore 0x00000001070b3532 -[UIViewController setValue:forKey:] + 87
5 UIKitCore 0x0000000106d7cada -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001045e3ddd -[NSArray makeObjectsPerformSelector:] + 317
7 UIKitCore 0x0000000106c966d1 -[UINib instantiateWithOwner:options:] + 1814
8 UIKitCore 0x00000001070ba6f2 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
9 UIKitCore 0x00000001070bb07c -[UIViewController loadView] + 177
10 UIKitCore 0x00000001070bb38e -[UIViewController loadViewIfRequired] + 175
11 UIKitCore 0x00000001070bbbe0 -[UIViewController view] + 27
12 UIKitCore 0x000000010719cee3 -[UIWindow addRootViewControllerViewIfPossible] + 122
13 UIKitCore 0x000000010719d5fe -[UIWindow _setHidden:forced:] + 294
14 UIKitCore 0x00000001071b082d -[UIWindow makeKeyAndVisible] + 42
15 UIKitCore 0x000000010698612c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4595
16 UIKitCore 0x000000010698b527 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1623
17 UIKitCore 0x000000010722de3e __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 866
18 UIKitCore 0x000000010722a403 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
19 UIKitCore 0x000000010722da7b -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 233
20 UIKitCore 0x000000010722e435 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1085
21 UIKitCore 0x00000001071ebb31 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 795
22 UIKitCore 0x00000001071eb7db -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 435
23 UIKitCore 0x000000010723092c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 584
24 UIKitCore 0x0000000107231256 _performActionsWithDelayForTransitionContext + 100
25 UIKitCore 0x000000010723068b -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 221
26 UIKitCore 0x0000000107229aa1 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
27 UIKitCore 0x0000000106989d46 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 515
28 UIKitCore 0x00000001069bb856 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 357
29 FrontBoardServices 0x000000010f696dda -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
30 FrontBoardServices 0x000000010f6a1f43 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 271
31 FrontBoardServices 0x000000010f6a163a __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
32 libdispatch.dylib 0x0000000105a0d587 _dispatch_client_callout + 8
33 libdispatch.dylib 0x0000000105a10647 _dispatch_block_invoke_direct + 312
34 FrontBoardServices 0x000000010f6d63c8 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 30
35 FrontBoardServices 0x000000010f6d6080 -[FBSSerialQueue _performNext] + 457
36 FrontBoardServices 0x000000010f6d6660 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
37 CoreFoundation 0x000000010455bb31 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
38 CoreFoundation 0x000000010455b3a3 __CFRunLoopDoSources0 + 243
39 CoreFoundation 0x0000000104555a4f __CFRunLoopRun + 1263
40 CoreFoundation 0x0000000104555221 CFRunLoopRunSpecific + 625
41 GraphicsServices 0x000000010c6e11dd GSEventRunModal + 62
42 UIKitCore 0x000000010698d115 UIApplicationMain + 140
43 Swift TTT 0x00000001022a71b7 main + 71
44 libdyld.dylib 0x0000000105a7d551 start + 1
45 ??? 0x0000000000000005 0x0 + 5
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)


(Jon Shier) #2

It seems like you're setting an outlet on the view controller named boogie in your storyboard, but your code doesn't implement it. Check the outlets for your view controller and delete the one named boogie, or hook it up.

By the way, StackOverflow is probably the best place for issues like this.