Can I use NSURLCredentialStorage for HTTP Basic Authentication?

后端 未结 4 2068
时光说笑
时光说笑 2020-11-27 10:43

I have a cocoa class set up that I want to use to connect to a RESTful web service I\'m building. I have decided to use HTTP Basic Authentication on my PHP backend like so…<

4条回答
  •  情歌与酒
    2020-11-27 11:42

    I would note mikeabdullahuk's answer is good but also if you use NSURLCredentialPersistencePermanent instead of per session it will store the credentials in the users keychain so next time you can check NSURLCredentialStorage for a non nil value for the default credentials for a protection space and if you get a non nil value you can just pass the credentials in. I am using this method right now for a delicious.com client I am writing and it works very well in my tests.

提交回复
热议问题