I just downloaded Xcode 7 and ran my app through the 1.0 to 2.0 migrator and received five errors, two with the calculator, two with the iPhone LED toggle and one in the mail composer in my app.
For the caluclator, I received errors for the .toInt, saying "toInt is unavailable, use the Int() initializer. I marked the lines with the dashes.
@IBAction func launchEmail(sender: AnyObject) {
@IBOutlet weak var Screen: UILabel!
var firstNumber = Int()
var secondNumber = Int()
var isTypingNumber = false
var result = Int()
var operation = ""
@IBAction func number(sender: AnyObject) {
let number = sender.currentTitle
if isTypingNumber == true {
Screen.text = Screen.text! + number!!
} else {
Screen.text = number;
}
isTypingNumber = true
}
@IBAction func operation(sender: AnyObject) {
isTypingNumber = false
---- firstNumber = Screen.text!.toInt()!----------
operation = sender.currentTitle!!
}
@IBAction func equals(sender: AnyObject) {
---- secondNumber = Screen.text!.toInt()! ----------
if operation == "+" {
result = firstNumber + secondNumber
} else if operation == "-" {
result = firstNumber - secondNumber
} else if operation == "X" {
result = firstNumber * secondNumber
} else {
result = firstNumber / secondNumber
}
Screen.text = "\(result)"
}
@IBAction func clear(sender: AnyObject) {
firstNumber = 0
secondNumber = 0
isTypingNumber = false
result = 0
Screen.text = "\(result)"
}
For the phones LED, I had two errors. One was (on the first line with dashes) saying, "Cannot invoke 'LockForConfiguration' with an argument type of (nil). On the second (line dashed) it said "Extra argument 'error' in call"
@IBAction func toggleFlash(sender: AnyObject) {
if let device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) where device.hasTorch {
---- device.lockForConfiguration(nil) -------
if (device.torchMode == AVCaptureTorchMode.On) {
device.torchMode = AVCaptureTorchMode.Off
} else {
---- device.setTorchModeOnWithLevel(1.0, error: nil) -------
}
device.unlockForConfiguration()
}
}
Finally for the mail composer, On the dashed line, I got an error the said "'MFMailComposerResult' does not have a member named 'value'." @IBAction func launchEmail(sender: AnyObject) {
if (MFMailComposeViewController.canSendMail()) {
let emailTitle = "Utilibox Feedback"
let messageBody = "I am experiencing the following issues:"
let toRecipents = ["utiliboxfeedback@gmail.com"]
let mc:MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
self.presentViewController(mc, animated: true, completion: nil)
} else {
print("No email account found.")
}
}
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
switch result.value {
case MFMailComposeResultCancelled.value:
print("Cancelled")
case MFMailComposeResultSaved.value:
print("Saved")
case MFMailComposeResultSent.value:
print("Sent")
case MFMailComposeResultFailed.value:
print("Failed")
default:
break
}
self.dismissViewControllerAnimated(true, completion: nil)
}
What exact things should I change these to to make them work. I appreciate all help. THANK YOU SO SO MUCH :) :)