In some context: I'm trying to clear part of my FMDB code. My table has many columns, and the method in FMDB that I need to use is the one that expects a variable number of arguments, similar to the method of the NSString +stringWithFormat: class.
Example:
[db executeUpdate:@"insert into test (a, b, c, d, e) values (?, ?, ?, ?, ?)" , @"hi'", // look! I put in a ', and I'm not escaping it! [NSString stringWithFormat:@"number %d", i], [NSNumber numberWithInt:i], [NSDate date], [NSNumber numberWithFloat:2.2f]];
When a table has only 5 columns, it is not so bad, but when a column has 20+, it starts to become hairy.
I would like to create a dictionary with all the information about db abstraction and dynamically build these queries. My question is ... How do I fake this method in Objective-C by expecting a variable number of arguments and, instead, maybe pass it an NSArray?
Additional Information:
How to write a method that takes a variable number of arguments, for example NSString + stringWithFormat :?
source share