Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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

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];
__mick
nodejs,coffee-script等で遊んでいます。 https://github.com/mick-whats
https://twitter.com/mick_x_
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
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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
ユーザーは見つかりませんでした