For a JSON request to a server, I am using some code that includes a value for the length of a string as follows:
[request addValue:[NSString stringWithFormat:@"%d", [body length]] forHTTPHeaderField:@"Content-Length"];
This code, however, is throwing a warning that %d
should not be used for the length and the code be changed to %lu(unsigned long)
.
I am following the accepted answer here and numerous other places that says:
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
Should I follow Xcode's suggestion? I am a bit reluctant to change working code as I have found XCode's suggestions to occasionally cause unintended problems.
Thanks in advance for any suggestions