Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@__mick

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

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

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];

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

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

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

[database executeUpdate:@"UPDATE testTable SET id = ?, name = ?, age = ?;",id,name];
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
2
Help us understand the problem. What are the problem?