Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Daniel Ahmed
Daniel Ahmed
2,034 Points

iOS Xcode Simulator/code bug

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var visualLabel: UILabel!

    var currentCount: Int = 0

    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.
    }



    @IBAction func counter(sender: UIButton) {

    currentCount = currentCount + 1

    visualLabel.text = "This button has been pressed \(currentCount)"

    visualLabel.textColor = UIColor.blueColor()

    }


}

When I run this on the iOS simulator it just stays on the main screen. It doesn't actually run the app at all. I can't find out why can anyone help?

1 Answer

Here are some suggestions, as this happens to me some times with Xcode.

  1. Try closing out the iOS Simulator (if it is open), and Xcode as well. Then access your project by clicking on the Xcode program first and then selecting your project in the recent projects (rather than clicking on the .xcodeproj file directly).

  2. Try cleaning your product by selecting the product tab in the Xcode toolbar on top of your screen when Xcode is the active program and selecting Clean. Then try running it.

I hope these suggestions help, and please feel free to reply to me with how it goes. Also, I am just curious as to what version of Xcode you are running, and if any error messages occur when you try to run your application in the simulator?

Daniel Ahmed
Daniel Ahmed
2,034 Points

None of these work for me and i'm currently running Xcode 6.1.1. But what I did notice i get this error from the Debug area "libc++abi.dylib: terminating with uncaught exception of type NSException"

I see, try using exception breakpoints to try to identify the issue causing this problem. Check out the video about Exception Breakpoints in Application Debugging to see the process of doing so (if you haven't done so already). A quick thing to check for that might cause this is to check for orphaned outlets within your project (Check out your view controller's connections inspector in Interface Builder is a good start). Good luck!