Realm object has been deleted or invalidated

后端 未结 12 1102
粉色の甜心
粉色の甜心 2020-12-13 08:20

When I start my app, I perform an API call to see whether there\'s new data available. The data is stored in my local Realm database, and some of it is displayed in the init

12条回答
  •  一生所求
    2020-12-13 09:02

    I got a really nice way to catch a RLMException within Swift.

    Currently Swift doesn't show where a RLMException happened.

    In Realm/RLMUtil.mm:266, there is the definition for RLMException.

    If you change the code to generate a swift error,

    Xcode now can show you where the exception occurred.

    Now it is a part of Swift.

    // Realm/RLMUtil.mm:266
    static NSException *RLMException(NSString *reason, NSDictionary *additionalUserInfo) {
        // add some code to generate a swift error. E.g. division-by-zero.
        int a = 0;
        if (reason == nil) {
            a = 1;
        }
        NSLog(@"calculating 1 / %d = %f", a, 1 / a);
    
        ... remainder of the original code...
    }
    

提交回复
热议问题