objective c - Correct Structure to check for Errors using NSError -


I'm coding different routines and I'm doing my best to keep it organized and restructured.

The methods I am making are starting to look similar to this code:

  - Press the (IBAction) button: (ID) sender {// of this document Create a document shopping list with [something to do: & amp; Error]; If (error) {[NSAPP present error: & amp; Error]; Return zero; } [Auto doSomethingElse: & amp; Error]; If (error) {[NSAPP present error: & amp; Error]; Return zero; } [Auto doYetSomethingElse: & amp; Error]; If (error) {[NSAPP present error: & amp; Error]; Return zero; }}  

I like NSError, but it seems to be a very strange way of handling all of my errors.

I have some ideas about alternate methods:

a) Error probes can be made in the doSomething, doSomethingElse etc., but then I would like to return some kind of press Without checking the button will not be able to exit the press method, which is back to me in a similar structure.

b) I can install the NSIRRR as the key to preserve the value, but it seems to be a bit deeply wrong. I am very aware of the possibility of misbehaving with KVO, so I am probably trying to do everything without it.

Surely I'm really missing something original? Is there a pattern that can help me? Or is this structure okay?

I think none of the responses presented here are not recommending Apple is working .

Actually you should not check the NSError object to determine if there was a problem. You check that there is a problem by checking the value returned by the method which takes the indicator an indicator in NSError .

From:

Important Success or failure is shown by the return value of the method. Although the cocoa memory domains in the cosmic object indirectly returning coca methods guarantee the return of such items if the method is directly zero or NO or NO or NO indicates failure, you should always check that the return value is not zero or before attempting to do anything with the NSError object .


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -