When i pass an NSString as object for a key in an NSMutableDictionary it seems to contain escape characters as regular characters. How can I remove them? I have tried stringByReplacingOccurrencesOfString:@”\” withString:@”” byt it does not work.
Here is my code and output:
Code:
NSString* fql1 = [NSString stringWithFormat:@"SELECT page_id FROM place WHERE distance(latitude,longitude,\"%@\",\"%@\") < 1500 AND checkin_count > 5", latitude, longitude];
NSString* fql2 = [NSString stringWithFormat:@"SELECT author_uid, post_id, timestamp, tagged_uids, message FROM checkin WHERE page_id IN (select page_id from #PlaceQuery)"];
NSString* fql = [[NSString stringWithFormat:@"{\"PlaceQuery\":\"%@\",\"CheckInQuery\":\"%@\"}",fql1,fql2] stringByReplacingOccurrencesOfString:@"\\" withString:@""];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"queries"];
NSLog(@"%@", fql);
NSLog(@"%@", params);
Output from NSLog(@”%@”, fql):
{“PlaceQuery”:”SELECT page_id FROM place WHERE distance(latitude,longitude,”37.331693″,”-122.030457″) < 1500 AND checkin_count > 5″,”CheckInQuery”:”SELECT author_uid, post_id, timestamp, tagged_uids, message FROM checkin WHERE page_id IN (select page_id from #PlaceQuery)”}
Output from NSLog(@”%@”, params):
{
queries = “{\”PlaceQuery\”:\”SELECT page_id FROM place WHERE distance(latitude,longitude,\”37.331693\”,\”-122.030457\”) < 1500 AND checkin_count > 5\”,\”CheckInQuery\”:\”SELECT author_uid, post_id, timestamp, tagged_uids, message FROM checkin WHERE page_id IN (select page_id from #PlaceQuery)\”}”;
}
I have been searching for hours for a solution so thanks A LOT in advance 😉
This turned out to be an issue about permissions… yes, embarrasing…
What confused me was that the escape characters was in the response output…
Thanks @williham and @nielsbot