开发者

Encoding on NSURLConnection

I need to load data from a REST service, but the result is always (null) when I have any accentuation. I开发者_运维百科 know this is an encoding problem but NSUrlConnection gives me no solution. The best result I got is to have all my text with strange codes in the place of the accentuated characters.

I already tried to use NSUrl like the following code and it works, but I need to set two headers for this connection.

NSURL *nsurl = [[NSURL alloc] initWithString:url];
NSString *data = [[NSString alloc] initWithContentsOfURL:nsurl encoding: NSUTF8StringEncoding error: nil];

Well I could have two solutions for this taks, adding headers do NSUrl connection or manage to make the encoding to work in NSURLConnection.

Does anyone have a solution?


You can add header fields for your request in an NSMutableURLRequest instance with setValue:forHTTPHeaderField:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜