ios - How to handle below schema, my requirement is split queries and then integrate queries to database related code? how can i do? -
i m getting string server, have split these queries , implement local db code, how can (handle string like, split , converting)
sql://query=create%20table%20employee%20(empid%20int%2c%20empname%20text%2c%20age%20int%2c%20gender%20text%2c%20sync%20int)&sync=1&syncquery=select%20*%20from%20employee%20where%20sync%3e0%20limit%2010&onadded=update%20employee%20set%20sync%3d0%20where%20empid%3d%27%25empid%25%27&onmodified=update%20employee%20set%20sync%3d0%20where%20empid%3d%27%25empid%25%27&ondeleted=delete%20from%20employee%20where%20empid%3d%27%25empid%25%27&syncfrequency=300"];
here done decoding process,by using below code
nsstring *decodedtext = [query stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]; nslog(@"original text: %@", decodedtext);`
but want split queries using keys(query, sync,sync query....), how can do
please me
nsstring *query=[nsstring stringwithformat:@"%s","query=create%20table%20employee%20(empid%20int%2c%20empname%20text%2c%20age%20int%2c%20gender%20text%2c%20sync%20int)&sync=1&syncquery=select%20*%20from%20employee%20where%20sync%3e0%20limit%2010&onadded=update%20employee%20set%20sync%3d0%20where%20empid%3d%27%25empid%25%27&onmodified=update%20employee%20set%20sync%3d0%20where%20empid%3d%27%25empid%25%27&ondeleted=delete%20from%20employee%20where%20empid%3d%27%25empid%25%27&syncfrequency=300"]; nsstring *decodedtext = [query stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]; nsarray *firstsplit = [decodedtext componentsseparatedbystring:@"&"]; for(nsstring *currentstring in firstsplit) { nsdictionary *dict = [[nsmutabledictionary alloc] init]; [dict setvalue:[[currentstring componentsseparatedbystring:@"query="] lastobject] forkey:@"query"]; [dict setvalue:[[currentstring componentsseparatedbystring:@"sync="] lastobject] forkey:@"sync"]; [dict setvalue:[[currentstring componentsseparatedbystring:@"syncquery="] lastobject]forkey:@"syncquery"]; [dict setvalue:[[currentstring componentsseparatedbystring:@"onadded="] lastobject] forkey:@"onadded"]; [dict setvalue:[[currentstring componentsseparatedbystring:@"ondeleted="] lastobject] forkey:@"ondeleted"]; [dict setvalue:[[currentstring componentsseparatedbystring:@"syncfrequency="] lastobject] forkey:@"syncfrequency"]; nslog(@"%@",dict); }
Comments
Post a Comment