我做错了什么?这是一个非常简单的语句,但无法找出导致它失败的原因
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.ason=-__ sent字符串注释:无法识别的选择器已发送到实例0x68a93f
Note.h
#import <Foundation/Foundation.h>
@interface Note : NSObject
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *comment;
@property (nonatomic) int fkID;发布于 2012-02-20 13:55:09
这就是我最终要做的事情。
NSString *sql = [NSString stringWithFormat:@"INSERT INTO notes (title, comment, fkid) values ('%@', '%@', %i)", title, comment, fkid];
isSuccess = [db executeUpdate:sql];它工作得很好。
发布于 2012-02-19 15:14:15
看看FMDB usage吧。
[db executeUpdate:@"INSERT INTO notes VALUES (?,?,?)", title, comment, [NSNumber numberWithInt:fkID]]; 提供给-executeUpdate:方法(或接受va_list作为参数的任何变体)的所有参数都必须是对象。
https://stackoverflow.com/questions/9347377
复制相似问题