JiteshW
JiteshW

Reputation: 2205

Realm: Getting -[__NSArrayM UTF8String]: unrecognized selector sent to instance

I am Getting crash in app upgrade scenario. It gives below error and warning. But this issue happens only when I have AppStore build installed and on top of that I install my new testflight build. If I install developer build on AppStore build, than it works fine.

Error:

[__NSArrayM UTF8String]: unrecognized selector sent to instance

Warning: An RLMRealm instance was deallocated during a write transaction and all pending changes have been rolled back. Make sure to retain a reference to the RLMRealm for the duration of the write transaction.

It crashes straight away when you tap app icon, So, I dont have any stack trace.

Realm version: 0.96.3 & Xcode version: 7.3

Below is my migration code for that.

RLMRealmConfiguration *config = [RLMRealmConfiguration defaultConfiguration];
    config.schemaVersion = 3;

    if (oldSchemaVersion < 2)
    {
        [migration enumerateObjects:DB_Class1.className
                              block:^(RLMObject *oldObject, RLMObject *newObject) {
                                  newObject[@"thisIsArray_1"] = nil;
                              }];
        [migration enumerateObjects:DB_Class2.className
                              block:^(RLMObject *oldObject, RLMObject *newObject) {
                                  newObject[@"thisIsInt_1"] = 0;
                                  newObject[@"thisIsInt_2"] = 0;
                                  newObject[@"thisIsInt_3"] = 0;
                              }];            
    }

All of the above newObjects are added in this version only.

Update 1: I can see deleteRealmIfMigrationNeededfor android. Is there any eqvivalent in iOS? I only found deleteAllObjects. If so, thn I can simply delete my old realm data and save new one.

Thanks.

Upvotes: 0

Views: 566

Answers (1)

AustinZ
AustinZ

Reputation: 1787

Realm Cocoa added the deleteRealmIfMigrationNeeded option (on RLMRealmConfiguration) in version 0.102.0. This should allow you to sidestep your migration issues. See the change notes here.

Upvotes: 1

Related Questions