Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
scroll top