سؤال

I was looking at the NSURLConnection class today, specifically researching method:

- (void) connection: (NSURLConnection *) conn didFailWithError:(NSError *)error {

Turns out it is deprecated. Documentation seems to offer no hints as to the replacement of this method. How should i proceed finding it please?

enter image description here

enter image description here

هل كانت مفيدة؟

المحلول

In most cases, deprecation notices include the replacement method. See Deprecated UITableViewDelegate Methods and Deprecated NSFileManager Methods for an examples. In this case, the documentation is a little confusing, and you should let the doc writers know that. At the bottom of the web page there's a place to provide feedback.

As other responders have noted, there's little actual change here, since they just moved the old informal protocol into a formal protocol. But the docs are misleading and they should fix it.

Here's a copy of the feedback I've sent:

This page gives the impression that you shouldn't use these methods anymore. In fact, you should, but they've been moved to a formal protocol. This should be stated more clearly in the deprecation notice.

نصائح أخرى

connection:didFailWithError: is still available; it's just been moved to an official protocol (NSURLConnectionDelegate). You just need to make sure your class declares that it implements the protocol:

@interface YourClass : NSObject <NSURLConnectionDelegate> { ... }

The reason is that in IOS5 that informal protocol has been formalised as NSURLConnectionDelegate and the documentation sucks.

Check the documentation for NSURLConnectionDelegate Protocol. It looks like that method you're looking for is in there.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top