1

I'm writing my first Objective-C Class. It's responsible for interaction with an HTTP SSO authentication service.

The process requires multiple HTTP transactions in order to complete. The Class acts as a NSURLConnectionDelegate for its own NSURLConnection object. The NSURLConnectionDelegate object operates asynchronously.

I need to disallow an authentication attempt when another is in progress. I have an idea of how to do that myself, but want to know of design patterns for this situation.

My existing idea is to check an instance variable to see if an authentication is underway and if so simply not start another. However, I'm unsure how to communicate this back to the calling Class. My method presently returns void. Should I use an NSError and return that if another authentication attempt is underway?

  • 2
    Instead of just asking for a design pattern, provide us with your existing idea and point out the concerns you may have with it. Asking a specific question is more likely to get an answer than a generic request. – user53019 Sep 17 '13 at 18:51
  • Are you going to use semaphores? You should implement part of the solution then explain where you are getting stuck. – bneely Oct 3 '13 at 2:21
0

I decided to use a BOOL as a semaphore on my authentication method. If authentication is already underway, or complete then I return an NSError object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.