LoginSignup
0
0

More than 5 years have passed since last update.

Command failed due to signal: Illegal instruction: 4

Posted at

次の環境でSwiftアプリをビルドしたところ、タイトルのようなコンパイルエラーが出ました。

Xcode 7.0 beta 5

原因はoverrideしたメソッドの戻り値の型が誤っていたためでした。単純ミスです。

こちらがUITableViewControllerに記述した、エラーになるコードです。

// 間違えたコード
override func sectionIndexTitlesForTableView(tableView: UITableView) -> [String] {
    return ["a", "b", "c"]
}

UITableViewDataSourceのsectionIndexTitlesForTableViewはオプショナルを返すので、

// 正しいコード
override func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? {
    return ["a", "b", "c"]
}

と修正しました。これでコンパイルが通るようになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0