Dear Developers,
I am a beginner, and am trying to create a very basic calculator in Xcode.
I have been getting an error that I cannot solve, even after deleting all the code and starting again.
I hope someone can help me. Below is the page where the error is showing and below that is the code I have written so far. Thank you in advance.
In the Debug area is "(lldb)" highlighted in blue.
In AppDelegate.swift:
- In bold is the line that is receiving an error message below.
- On Xcode, the line is highlighted green and says "Thread 1: breakpoint 1.3"
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//Override point for customization after application launch.
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
/
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
In ViewController.swift:
import UIKit
enum modes {
case NOT_SET
case ADDITION
case SUBTRACTION
}
class ViewController: UIViewController {
var labelString:String = "0"
var currentMode:modes = modes.NOT_SET
var savedNum:Int = 0
var lastButtonWasMode:Bool = false
@IBOutlet weak var label: UILabel!
@IBAction func tapped0(sender: AnyObject) {tappedNumber(0)}
@IBAction func tapped1(sender: AnyObject) {tappedNumber(1)}
@IBAction func tapped2(sender: AnyObject) {tappedNumber(2)}
@IBAction func tapped3(sender: AnyObject) {tappedNumber(3)}
@IBAction func tapped4(sender: AnyObject) {tappedNumber(4)}
@IBAction func tapped5(sender: AnyObject) {tappedNumber(5)}
@IBAction func tapped6(sender: AnyObject) {tappedNumber(6)}
@IBAction func tapped7(sender: AnyObject) {tappedNumber(7)}
@IBAction func tapped8(sender: AnyObject) {tappedNumber(8)}
@IBAction func tapped9(sender: AnyObject) {tappedNumber(9)}
@IBAction func tappedPlus(sender: AnyObject) {
}
@IBAction func tappedMinus(sender: AnyObject) {
}
@IBAction func tappedEquals(sender: AnyObject) {
}
@IBAction func tappedClear(sender: AnyObject) {
}
func tappedNumber(num:Int) {
labelString = labelString.stringByAppendingString("\(num)")
updateText()
}
func updateText() {
guard let labelInt:Int = Int(labelString) else {
label.text = "Int conversion failed"
return
}
label.text = "\(labelInt)"
}
func changeMode(newMode:modes) {
}
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.
}
}