如何添加枚举到领域模型? RLMObject?

编程入门 行业动态 更新时间:2024-10-24 09:20:57
本文介绍了如何添加枚举到领域模型? RLMObject?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的serviceModel.h

This is my serviceModel.h

typedef NS_ENUM(NSInteger, OKServiceType) { OKServiceTypePending = 0, OKServiceTypeAccepted , OKServiceTypeStarted, OKServiceTypeCompleted, OKServiceTypeClosed, OKServiceTypeCancelled }; @interface serviceModel : RLMObject @property NSString *job_id; @property NSString *job_service_id; @property NSString *service_id; @property NSString *vendor_id; @property NSString *timeslot; @property NSString *points; @property OKServiceType *status; @property NSString *service_name; @property NSString *image_url; @property NSString *vendor_name; @property NSString *subservice_desc; @property NSString *subservice_id; @property NSString *display_datetime; @property NSString *status_text; @end RLM_ARRAY_TYPE(serviceModel)

我知道我们可以将属性类型添加为这些。但是我无法找到正确的方法来添加枚举给我的模型,因为领域只收集所有的模型,所以它由于这个

I know we can add the property type as These. But I cann;t find the proper way to add the enum to my models as realm collects all models on start only so it do crash due to this

@property OKServiceType *status;

我正在崩溃作为

错误错误Domain = NSCocoaErrorDomain代码= 3010模拟器中不支持远程通知

Error Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator"

UserInfo = {NSLocalizedDescription =远程通知不是支持在模拟器中} 2017-06-12 15:20:41.049 AppName [9974:157085]

UserInfo={NSLocalizedDescription=remote notifications are not supported in the simulator} 2017-06-12 15:20:41.049 AppName[9974:157085]

***由于未捕获的异常终止应用程序RLMException ,原因:'不能持久的属性'status'与不兼容的类型。添加到 ignoredPropertyNames:忽略方法'

*** Terminating app due to uncaught exception 'RLMException', reason: 'Can't persist property 'status' with incompatible type. Add to ignoredPropertyNames: method to ignore.'

任何帮助将不胜感激alot ..

Any Help would be appreciated alot..

推荐答案

也许您想将您的财产存储为 NSInteger ,这是一种受支持的类型,并创建方法返回您的整数值作为枚举类型为 OKServiceType 。

Maybe you want to store your property as an NSInteger which is a supported type and create a method which returns your integer value as an enum of type OKServiceType.

@property NSInteger statusInt; - (OKServiceType)status { return (OKServiceType)statusInt } - (void)setStatus(OKServiceType)status { self.statusInt = status }

更多推荐

如何添加枚举到领域模型? RLMObject?

本文发布于:2023-11-25 13:50:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630013.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模型   领域   RLMObject

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!