Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fmdb executeUpdate fails

Tags:

objective-c

What am I doing wrong? It's a very simple statement but couldn't figure out what causes it to fail

    FMDatabase *db = [FMDatabase databaseWithPath:appDelegate.databasePath];
    [db open];
        isSuccess = [db executeUpdate:@"INSERT INTO notes (title, comment, fk) values (?, ?, ?);", title, comment, fkID];

exception.name=NSInvalidArgumentException, exception.reason=-[__NSCFString comment]: unrecognized selector sent to instance 0x68a93f

Note.h

#import <Foundation/Foundation.h>

@interface Note : NSObject

@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *comment;
@property (nonatomic) int fkID;
like image 937
GaneshT Avatar asked Mar 28 '26 21:03

GaneshT


1 Answers

Take a look at FMDB usage.

[db executeUpdate:@"INSERT INTO notes VALUES (?,?,?)", title, comment, [NSNumber numberWithInt:fkID]];  

All arguments provided to the -executeUpdate: method (or any of the variants that accept a va_list as a parameter) must be objects.

like image 183
Parag Bafna Avatar answered Apr 02 '26 21:04

Parag Bafna