iphone - 如何为 iOS 应用程序创建自定义错误域?

标签 iphone objective-c ios cocoa-touch error-code

我是使用 Objective-C 为 iOS 应用程序编程的新手。如何创建自己的错误域和错误代码以在我自己的应用程序中使用?

最佳答案

根据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.

所以只要使用像@"com.company.myapp.ErrorDomain"这样的NSString。

关于iphone - 如何为 iOS 应用程序创建自定义错误域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7034762/

相关文章:

ios - 如何将 UIColor 转换为 HEX 并在 NSLog 中显示

iphone - 使用自定义格式访问当前系统日期

objective-c - [Facebook-iOS-SDK 4.0]如何从FBSDKProfile获取用户邮箱

objective-c - 没有从 Core Data 获取数据

ios - 在 Swift Playground 的时间轴 View 中添加链接

ios - 扩展 UIView 时出现 EXC_BAD_INSTRUCTION

ios - 无法通过在 Swift 3.2 中解析其显示为字符串格式来获取数组

iphone - 如何检测移动网站的触摸屏手机

objective-c - 如果表格 View 为空则显示标签

objective-c - 从代码中显示两个 NSTableView 项目的最简单的方法?