Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create custom error domains for iOS applications?

I am a newbie to programming in objective-C for iOS applications. How do I create my own error domains and error codes for use in my own application?

like image 443
Lopper Avatar asked Aug 12 '11 01:08

Lopper


2 Answers

According to the Error Handling Programming Guide:

You can create your own error domains and error codes for use in your own frameworks, or even in your own applications. It is recommended that the string constant for the domain be of the form com.company.framework_or_app.ErrorDomain.

So just use an NSString like @"com.company.myapp.ErrorDomain".

like image 139
EricS Avatar answered Nov 05 '22 15:11

EricS


If you wanted to really organize things, you could create a separate class with a bunch of class methods that run NSLogs in the console.

like image 39
Dylan Reich Avatar answered Nov 05 '22 15:11

Dylan Reich