I have a problem with a following sqlite query:
sql = [NSString stringWithFormat:#"Insert into table_name(height)values('%#')",heightarray];
I am getting heightarray from XML, the value of heightarray is:
array = ( "5'0\"-5'3\"",
"5'4\"-5'8\"",
"5'9\"-6'0\"" )
The \" is added implicitly for some reason, I don't know why?
It is causing problem. please help.
try to use
sql = [NSString stringWithFormat:#"Insert into table_name(height)values(?)"];
and then use
sqlite3_bind_text
If you're using sqlite try this wrapper it helps a lot
https://github.com/ccgus/fmdb
There are detailed examples how to use it.
Related
I am using Fmdb wrapper around Sqlite, everything is working fine.
Now I want to load data from a variable table, the table name is stored in an NSString. I don't know how to write query for that. Please help!
I never used FMDB Wrapper. But reading the Documetation, it looks like -executeQuery is a method from FMDatabase Class that takes the QueryString as a parameter and returns an object of FMResultSet Class. So, argument is of NSString type and you can use %# operator to add the dynamic string values in your QueryString.
Sample Code :
FMResultSet *results = nil;
results = [yourDB executeQuery:[NSString stringWithFormat:#"SELECT * FROM %#",variable_tableName]];
I have a Json return that has a string that sometimes inludes something like \Uf604 in the array (IE memo = "\Uf604";). I need to convert it to \U0001F604 if possible.
I tried to do something like stringByReplacingOccurrencesOfString but at that point when its in a string and it's been converted to ÔòÑ which I think it needs to be üòÑ to be displayed as a emoticon. I also tried
[str stringByReplacingOccurrencesOfString:#"Ô" withString:#"ü"];
But that didn't change anything. It still gets returned as ÔòÑ.
Any help would be appreciated!
I believe str = [str stringByReplacingOccurrencesOfString:#"Ô" withString:#"ü"]; is what you are trying to do.
stringByReplacingOccurrencesOfString:withString: doesn't change the string you are calling on but returns a new string with replaced characters.
I want to read Dbx file In my App from The Following site.
http://www.weather.gov/geodata/catalog/wsom/data/bp03my11.dbx
How i can do This?
Any suggestion or any Sample Source Code
since the format of the "dbx" file is something similiar to the CSV (Comma seperated values)
you can find the code that parses the CSV and put the pipe sign ("|") as your seperator
The following link is the sample about the flow of line-break seperated value
http://www.iphonedevsdk.com/forum/iphone-sdk-game-development/13753-tutorial-quiz-game.html#post64855
your attempt is seprating the line-break first and second seprating the | and populate it into NSArray / NSMutableArray / NSDictionary
For the url , you can access it :
NSError* error;
NSString* text = [NSString stringWithContentsOfURL:TheUrl encoding:NSASCIIStringEncoding error:&error];
Refer to : What is the "stringWithContentsOfURL" replacement for objective C?
or use ASIHTTPRequest to ease the steps
http://allseeing-i.com/ASIHTTPRequest/
i am getting the problem when i get the result from the xml api web service i use
NSString *productName = [[paramName stringByReplacingOccurrencesOfString:#"\"" withString:#""] mutableCopy];
paramName is the argument of the function, but it can't replace the \ string which are on database
please help me out... thanks.
i only want to replace \ to none #"" but its not working now... please help me.. !!
i tried before its working but its not working now .. !! :(
Probably, you meant #"\\", not #"\"". It looks like you're trying to kill quotes, not backslashes.
I am using RegexKitLite in an iPhone project and want to use regex to find words that start with the #-sign. For instance, "#home #chores", when searched, would return both words.
The regex string I am using is "(?m-s:#.*\\s*)". When I use this, though, I get a crash. When I use the same thing, but with a # instead of #, it works just fine: "(?m-s:#.*\\s*)". WTF?
I would much appreciate it if someone with a better understanding of regular expressions could help me on this. The tutorials I have seen so far have been near incomprehensible to me.
I did a modification of Manu's idea, just switching the location of the # in the regex.
/(#\b\w+)/
I tested it on a string with '#foo #bar #baz #lol' and it seemed to do what you're looking for in matching on the words and capturing them with the parens.
Have you tried something like that:
NSString *search = #"This is my #home string with #some tokens to be #found";
NSString *regex = #"\\b#(\\w+)";
NSArray *matches = NULL;
matches = [search componentsMatchedByRegex:regex];
// now matches should have { #"home", #"some", #"found" } values
I haven't tested that but should work.
This may sound too simple, but have you tried changing # to \# or \\#
Why not simply use /\b#\w+/?