I am using the functions describes HERE to access an sqlite database.
I am having issue with the function:
-(NSArray *)find:(NSString *)field from:(NSString *)table where:(NSString *)condition.
This function works well for when the condition is nil and when the condition is a string without any format or method; ie it works well when it is either of the following
NSArray *result = [[SQLiteManager singleton] find:@"field1,field2" from:@"tableName" where:nil];
NSArray *result = [[SQLiteManager singleton] find:@"field1,field2" from:@"tableName" where:@"field2=value"];
However, I have a condition that should read from a UITextField. for example
NSArray *result = [[SQLiteManager singleton] find:@"field1,field2" from:@"tableName" where:[NSString stringWithFormat:@"field3=%@",[textFieldName text]]];
Unfortunately, the code breaks when I try this giving me an Assertion Failure error. ANy reason why? Any help is greatly appreciated.
At the very least you probably want to put single quotes around your
%@. Like this:But in addition to that you may also want to escape the string.