Ios 将一个字符串插入另一个字符串
我正在开发iPhone应用程序。我有SQL查询:Ios 将一个字符串插入另一个字符串,ios,objective-c,syntax,nsstring,Ios,Objective C,Syntax,Nsstring,我正在开发iPhone应用程序。我有SQL查询: NSString *myRed = [NSString stringWithFormat: @"%1.4f", slideR.value]; [self insertData:@"INSERT INTO colour VALUES("+myRed+")"]; 它会产生语法错误。如何在字符串中插入字符串。在Java中,这种方法是可行的。 致以最诚挚的问候试试这个: NSString *myRed = [NSString stringWith
NSString *myRed = [NSString stringWithFormat: @"%1.4f", slideR.value];
[self insertData:@"INSERT INTO colour VALUES("+myRed+")"];
它会产生语法错误。如何在字符串中插入字符串。在Java中,这种方法是可行的。
致以最诚挚的问候试试这个:
NSString *myRed = [NSString stringWithFormat: @"%1.4f", slideR.value];
[self insertData:[NSString stringWithFormat:@"INSERT INTO colour VALUES(\"%@\")",myRed]];
如果您不想要“
,那么:-
[self insertData:[NSString stringWithFormat:@"INSERT INTO colour VALUES(%@)",myRed]];
希望它能对您有所帮助。您可以尝试编写查询并将字符串附加在一起
NSString *str = @"Your values";
NSString *query = [NSString stringWithFormat:@"INSERT INTO color VALUES(%@)", str];
[self insertData:query];