exc-bad-instruction

iOS Swift - EXC_BAD_INSTRUCTION on certain devices

只愿长相守 提交于 2019-12-06 15:29:54
I'm very new to Swift and iOS development but I've come across a bug that is causing my app to crash when running on the following devices: iPhone 4S iPhone 5 iPad 2 iPad Retina Here is the code that is being flagged up: // bin2dec - converts binary string into decimal string func bin2dec(input: String) -> String { var counter = countElements(input) var digit: Character var power = 1 var result = 0 while counter > 0 { digit = input[advance(input.startIndex, counter-1)] switch digit { case "0": result += 0 case "1": result += 1 * power default: power = power / 2 break } counter-- power *= 2 }

EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode =0x0) on Swift when working with multi-dimensional arrays

筅森魡賤 提交于 2019-12-05 14:06:41
I get this error when I try to create an array which contain arrays with enums. To illustrate better here's the code: let block1:Form[] = [Form.Circle, Form.Rectangle, Form.Triangle] let block2:Form[] = [Form.Rectangle, Form.Circle, Form.Triangle] let block3:Form[] = [Form.Rectangle, Form.Triangle, Form.Circle] let block4:Form[] = [Form.Circle, Form.Triangle, Form.Rectangle] let block5:Form[] = [Form.Triangle, Form.Circle, Form.Rectangle] let block6:Form[] = [Form.Triangle, Form.Rectangle, Form.Circle] var allBlocks:(Form[][])! These are the arrays holding the enums and the last one will hold

EXC_BAD_INSTRUCTION error

耗尽温柔 提交于 2019-12-02 18:17:06
问题 I know that there are a lot of questions about this error, but I haven't found solution for my problem, even if I read most of them. In view controller I'm trying to make my text view displaying top of text, instead of bottom of it. When there is only one textView, then everything works perfectly, but when I try do it with two of the, , then I get EXC_BAD_INSTRUCTION error. import UIKit import Social class ViewController: UIViewController { @IBOutlet weak var textViewA: UITextView! @IBOutlet

EXC_BAD_INSTRUCTION error

孤人 提交于 2019-12-02 09:28:47
I know that there are a lot of questions about this error, but I haven't found solution for my problem, even if I read most of them. In view controller I'm trying to make my text view displaying top of text, instead of bottom of it. When there is only one textView, then everything works perfectly, but when I try do it with two of the, , then I get EXC_BAD_INSTRUCTION error. import UIKit import Social class ViewController: UIViewController { @IBOutlet weak var textViewA: UITextView! @IBOutlet weak var textViewB: UITextView! override func viewDidLoad() { super.viewDidLoad() } override func

Simple Swift Fibonacci program crashing (Project Euler 2)

若如初见. 提交于 2019-11-28 02:18:52
I am trying to solve the second problem on Project Euler. The problem is as follows: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. I think I've written a solution, but when I try to run my code it crashes my Swift playground and gives me this error message: Playground execution aborted: Execution was interrupted, reason: EXC_BAD

Timestamp function that has been working reliably just caused EXC_BAD_INSTRUCTION

梦想与她 提交于 2019-11-27 16:23:08
I have been using this function to generate a time stamp. I found it somewhere here on Stack Overflow. @objc public class var timestamp: String { return "\(Int(NSDate().timeIntervalSince1970 * 1000))" } It has been working without issue, but I just got a EXC_BAD_INSTRUCTION: fatal error: floating point value cannot be converted to Int because it is greater than Int.max As the development of this app is nearing completion it makes me nervous to all of the sudden see it cause a EXC_BAD_INSTRUCTION. This is running in the Simulator, but I have a valid date and time set. Any ideas or suggestions