exc-bad-instruction

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP,subcode=0x0)

时光总嘲笑我的痴心妄想 提交于 2019-12-24 17:29:58
问题 So close to actually getting this app moving. There is just one more problem. Now, my app will run, and it will give me an error when the next view controller is trying to show. I am showing a ViewController with a quote and an author. I get this error Thread 1: EXC_BAD_INSTRUCTION (code=EXC_1386_INVOP,subcode=0x0) The output is as follows: fatal error: unexpectedly found nil while unwrapping an Optional This is the code with the error: import Foundation import UIKit import Social class

Exc_bad_instruction with SWRevealViewController

流过昼夜 提交于 2019-12-24 16:52:06
问题 Background My app has one MainViewController with a UIButton which leads to another ViewController when pressed. In the second ViewController is a UIBarButtonItem which has a "Back" segue to the MainViewController. Everything has worked fine, until now when I programmed a slide out menu with help from SWRevealViewController and I followed this Jared Davidson tutorial https://www.youtube.com/watch?v=8EFfPT3UeWs (simple, general and easy) Problem The slide out menu works perfectly, but now when

iOS Swift - EXC_BAD_INSTRUCTION on certain devices

蓝咒 提交于 2019-12-23 02:32:12
问题 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"

Simple Swift Fibonacci program crashing (Project Euler 2)

假装没事ソ 提交于 2019-12-17 17:13:57
问题 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

Timestamp function that has been working reliably just caused EXC_BAD_INSTRUCTION

北城以北 提交于 2019-12-17 14:54:19
问题 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

Swift: decodeObjectForKey crashes if key doesn't exist

丶灬走出姿态 提交于 2019-12-13 05:53:54
问题 I'm unarchiving a Swift class with the following Swift code: required convenience init(coder decoder: NSCoder) { self.init() horseID = decoder.decodeIntegerForKey("horseID") name = decoder.decodeObjectForKey("name") as String! // if the thumb key does not exist, the following line crashes thumb = decoder.decodeObjectForKey("thumb") as UIImage! } The "thumb" class member was added later. I have an older archive file without the thumb data in it. Apple's documentation says that unarchiving a

Swift Google Directions API JSON - EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

青春壹個敷衍的年華 提交于 2019-12-11 05:59:15
问题 I am trying to get directions data using Google API, but it's keep crashing. Here is my code: let baseURLDirections = "https://maps.googleapis.com/maps/api/directions/json?" var selectedRoute: Dictionary<NSObject, AnyObject>! var overviewPolyline: Dictionary<NSObject, AnyObject>! var originCoordinate: CLLocationCoordinate2D! var destinationCoordinate: CLLocationCoordinate2D! var originAddress: String! var destinationAddress: String! func getDirections(origin: String, destination: String,

How to pull random item out of an array in Swift?

二次信任 提交于 2019-12-07 18:32:45
问题 I'm trying to pull a random item out of an array. When I run, it works about 50/50 between pulling a random item and giving me this error "EXC_BAD_INSTRUCTION". Any idea what's going on? Right now my code looks like this: BEFORE Solution func randomCard() -> Card { let randomIndex = Int(arc4random()) % cardArray.count let randomCard = cardArray[randomIndex] cardArray.removeAtIndex(randomIndex) return randomCard } After func randomCard() -> Card { let randomIndex = arc4random_uniform(UInt32

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

删除回忆录丶 提交于 2019-12-07 10:54:29
问题 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,