我的JSON在服务器上,假设我的网址是如何使用身份验证从服务器获取JSON数据?
https://abc.companyname.com/posts/list/10
当我粘贴URL在浏览,它要求我用户名和密码。当我输入这些证书时,它会返回一些JSON格式的数据,如下所示。
[{"id":"5","picture":"myimage.jpg","name":"Usman Zafar","type":"textonly","message":"Woo this is demo and it looks good thanks adeco","image":null,"video_id":null,"datecreated":"2013-10-17 10:14:02","totalLikes":0,"totalComments":0,"commentsData":null},
{"id":"6","picture":"default.jpg","name":"Usman Zafar","type":"textonly","message":"Hello this is the demo of another post but no image","image":null,"video_id":null,"datecreated":"2013-10-17 10:31:04","totalLikes":0,"totalComments":0,"commentsData":null},
{"id":"7","picture":"default.jpg","name":"Usman Zafar","type":"textonly","message":"Hello this is the demo of another post but no image","image":null,"video_id":null,"datecreated":"2013-10-17 10:31:24","totalLikes":0,"totalComments":0,"commentsData":null},
{"id":"11","picture":"myimage_9.jpg","message":"Regukar Text comments no.772"}]}]
我问题是
如何在iPhone编程认证(用户名+密码)创建NSURLConnection的?
如果需要关于问题的任何其他数据,请通过评论让我知道。
谢谢
可能的复制http://stackoverflow.com/questions/1973325/nsurlconnection-and-basic-http-authentication – Priyatham51
我看到的是,它使用的NSMutableString,其中因为我没有这样的对象。 – Duaan
NSMutableString是一个可变字符串,也就是可以编辑其内容的字符串。你可以从你的字符串中创建NSMutableString。 Ex NSMutableString * newString = [[NSMutableString alloc] initWithString:@“yourString”]; – Priyatham51