For the More Curious: Credentials

When you try to access a web service, it will sometimes respond with an authentication challenge, which means Who the heck are you? You then need to send a username and password (a credential) before the server will send its genuine response.

There are objects that represent these ideas. When the challenge is received, your connection delegate is sent a message that includes an instance of NSURLAuthenticationChallenge. The sender of that challenge conforms to the NSURLAuthenticationChallengeSender protocol. If you want to continue to get the data, you send back an instance of NSURLCredential, which typically looks something like this:

-​ ​(​v​o​i​d​)​c​o​n​n​e​c​t​i​o​n​:​(​N​S​U​R​L​C​o​n​n​e​c​t​i​o​n​ ​*​)​c​o​n​n​ ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.