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?

有帮助吗?

解决方案

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".

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top