2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

FMDBでEXC_BAD_ACCESSが出た場合の対処法メモ

2
Posted at

このような場所でエラーが出て止まる時があります。

FMDatabase.m
// FIXME - someday check the return codes on these binds.
    else if ([obj isKindOfClass:[NSData class]]) {

SQL文の"?"に引数がセットできない場合に起こるようです。
以下の様なSQLを投げたとして

[database executeUpdate:@"UPDATE testTable SET id = ?, name = ?;",self.id,self.name];

引数の型がおかしい場合はエラーになります。数値やBool値はNSNumberで渡す必要があります。

[database executeUpdate:@"UPDATE testTable SET id = ?, name = ?;",
    [NSNumber numberWithInt:self.id],self.name];

初歩的ですが、SQL文の"?"の数と引数の数が合わない場合も同様のエラーになるようです。

[database executeUpdate:@"UPDATE testTable SET id = ?, name = ?, age = ?;",id,name];
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?