我有这个 NSString 格式:
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", list[0]];
但大多数时候数组列表可能为空,导致编译器出现问题,所以如果可能的话,我想在其中添加一个方法 if else,如果数组为空,他会在其中放置一个空字符串作为@""
我试过这种方式,就是不行:
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", [list[0] : @""] ];
我该怎么做?
最佳答案
试试这个
comandoInsert = [NSString stringWithFormat:@"INSERT INTO fazerbem_clients (image) Values('%@')", list.count ? list[0] : @"" ];
关于ios - IF Else 方法,在 NSString 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23329788/