KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In python it is easy to build a dictionary or array and pass it unpacked to a function with variable parameters I have this: - (BOOL) executeUpdate:(NSString*)sql, ... { And the manual way is this: [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]]; But I can't hardcode the parameters I'm calling, I want: NSMutableArray *values = [NSMutableArray array]; for (NSString *fieldName in props) { .. .. [values addObject : value] } [db executeUpdate:@"insert into test (a, b, c, d, e) values (?, ?, ?, ?, ?)" ,??values];
Tags (comma-separated)
Save Edits
Cancel