In C the definition of NULL is 0, and in Objective-C NO is aliased to FALSE that is aliased to 0, so basically returning NULL is the same thing as returning NO.
The problem is that, as per the documentation:
This method is called before any attempt to authenticate is made.
If you return NO, the connection does not consult the credential
storage automatically, and does not store credentials. However, in
your connection:didReceiveAuthenticationChallenge: method, you can
consult the credential storage yourself and store credentials
yourself, as needed.
Not implementing this method is the same as returning YES.
Instead of returning NULL, return YES as per the default implementation
EDIT: NO is aliased to (BOOL)0, not to false that is a true boolean type
Specifically the definition of YES/NO are in objc.h
typedef signed char BOOL;
// BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
// even if -funsigned-char is used.
#define OBJC_BOOL_DEFINED
#define YES (BOOL)1
#define NO (BOOL)0
EDIT: As pointed out in the comments below by @AminNegm-Awad mine is just a (probably over)simplification of the NULL value, since 0 is how it is finally evaluated but it's not its real value.
/*
* Type definitions; takes common type definitions that must be used
* in multiple header files due to [XSI], removes them from the system
* space, and puts them in the implementation space.
*/
#ifdef __cplusplus
#ifdef __GNUG__
#define __DARWIN_NULL __null
#else /* ! __GNUG__ */
#ifdef __LP64__
#define __DARWIN_NULL (0L)
#else /* !__LP64__ */
#define __DARWIN_NULL 0
#endif /* __LP64__ */
#endif /* __GNUG__ */
#else /* ! __cplusplus */
#define __DARWIN_NULL ((void *)0)
#endif /* __cplusplus */
In fact by looking in <sys/_types.h> you can find out that __DARWIN_NULL, for objective-c code, is evaluated to ((void *)0) (verifiable by writing __DARWIN_NULL in xcode and cmd+clicking it) thus from @AminNegm-Awad comment:
An integer constant expression with the value 0, or such an expression
cast to type void *, is called a null pointer constant.55) If a null
pointer constant is converted to a pointer type, the resulting
pointer, called a null pointer, is guaranteed to compare unequal to a
pointer to any object or function." As an integral it is 0 (null
pointer constant). If it is a pointer, it is the casting 0 to a
pointer.
In a C++ application, instead, __DARWIN_NULL evaluates to __null, a compiler internal.
BACK TO THE QUESTION:
The proxy delegate method to me seems a clean approach specially if you want to hide some of the NSURLConnectionDelegate methods. The approach is more or less the same for -(void) methods, the difference is that you don't need to return anything but just to call the delegated method. Now I'm not able to provide you with a full example, but this evening I'll post something
NSURLConnection, but instead from your custom subclass - michaelsdelegateasid<myNewDelegate,NSURLConnectionDelegate> delegate. No need for proxy delegate, and you can callrespondsToSelector:on methods from either protocol. - Jack