I Want to make a string like below
contentlist=["{\"id\":\"id1\"}"]
How can i achieve this ?
I tried with NSString method stringWithFormat:@"contentlist=[\"%@\"]
but it has \ character when you copy that string and paste it into textedit or in stickies or anywhere.
if you print this line that it will display like contentlist=["{"id":"id1"}] that i dont want.
Edited :
Here is my code..
NSString *stringUrl = <MY SERVER URL STRING>
NSString *param = [NSString stringWithFormat:@"contentlist=[%c%@%c]",34,header,34];
NSData *postData = [param dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu",(unsigned long)[postData length]];
NSError *error;
NSMutableURLRequest *req = [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:stringUrl parameters:nil error:&error];
req.timeoutInterval= 40.0;
[req setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[req setValue:postLength forHTTPHeaderField:@"Content-Length"];
[req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[req setHTTPBody:postData];
And my header value is..
{\"id\":\"21ca7309\",\"indexVersion\":0,\"modified\":1501694202014,\"created\":1501691797232,\"modifiedBy\":\"42bebd87be6ddd4a\",\"name\":\"abcd\"}
How my param value look like in debug mode..
@"contentlist=[\"{\"id\":\"21ca7309\",\"indexVersion\":0,\"modified\":1501694202014,\"created\":1501691797232,\"modifiedBy\":\"42bebd87be6ddd4a\",\"name\":\"abcd\"}\"]
And how I need to pass is like :
contentlist:["{\"id\":\"21ca7309\",\"indexVersion\":0,\"modified\":1501694202014,\"created\":1501691797232,\"modifiedBy\":\"42bebd87be6ddd4a\",\"name\":\"abcd\"}"]
dataUsingEncodingon array