i was trying to insert a string into database having multiple value using componentsSeparatedByString:@",". I am getting all the values in "arrayp1net" but problem is how to make a string that contains all the values of array "arrayp1net" separated by comma (,)?
if(p1h < 18)
{
for(int k=0;k<[arrayp1 count];k++)
{
if([[hcar1 objectAtIndex:1]intValue] >= [[ar33 objectAtIndex:k] intValue])
{
NSString *str = [NSString stringWithFormat:@"%d",[[[arrayp1 objectAtIndex:k] text] intValue] -1];
[arrayp1net addObject:str];
}
else
{
NSString *str = [NSString stringWithFormat:@"%d",[[[arrayp1 objectAtIndex:k] text]intValue]];
[arrayp1net addObject:str];
player1netscore = [NSString stringWithFormat:@"%@",arrayp1net];
}
}
yes i need the same but i have to insert in database in one row of a column with query, so that when i am going to fetch, i fetch all as it is.
query=[NSString stringWithFormat:@"insert into normalscoring
(gameid,coursename,p1,p2,p3,p4,p1s,p2s,p3s,p4s,gameDate,p1nets,p2nets,p3nets,p4nets)
values (\'%@\',\'%@\',\'%@||%@\',\'%@||%@\',\'%@||%@\',\'%@||%@\',
',,,,,,,,,,,,,,,,,||0||0||0||0',
',,,,,,,,,,,,,,,,,||0||0||0||0',
',,,,,,,,,,,,,,,,,||0||0||0||0',
',,,,,,,,,,,,,,,,,||0||0||0||0',
\'%@\',',,,,,,,,,,,,,,,,,',
',,,,,,,,,,,,,,,,,',',,,,,,,,,,,,,,,,,',',,,,,,,,,,,,,,,,,')",
txtgameid.text,txtcoursename.text,txtplayer1.text,player1handicap,
txtplayer2.text,player2handicap,txtplayer3.text,player3handicap,
txtplayer4.text,player4handicap,txtdate.text];
here is what i am trying to do after if statement but getting exception
player1netscore = [NSString stringWithFormat:@"%@",arrayp1net];
arn11=[player1netscore componentsSeparatedByString:@","];
player1netscore=[[arn11 objectAtIndex:0] objectForKey:@"p1nets"];
NSLog(@"player1netscore...%@",player1netscore);