try this
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", list.count ? list[0] : @"" ];
题
I have this NSString with format:
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", list[0]];
but most times the array list can be empty, causing a problem in the compiler, so I would like if possible to add a method if else within it, in a way that if the array is empty there he puts an empty string as @""
I tried this way just does not work:
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", [list[0] : @""] ];
How I can do this?
解决方案
try this
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", list.count ? list[0] : @"" ];