Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
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. –  GlenH7 Sep 17 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 at 2:21
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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