Realm default property failed

When I create an object from restkit with a null property, the application crashes, saying:

The value or default value specified for the 'secondHeader' property in 'FZPublication'

but the defaultPropertyValues ​​method has a default value for the property

+(NSDictionary *)defaultPropertyValues {
    return @{
             @"serviceId" : @0,
             @"filterId" : @0,
             @"proccessDate" : @"",
             @"relation" : @"",
             @"header" : @"",
             @"text" : @"",
             @"remoteId" : @0,
             @"versionId" : @0,
             @"footer" : @"",
             @"secondHeader" : @"",
             @"companyRemoteId" : @0,
             };
}

My restkit mapping:

RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[FZPublication class]];
    [mapping addAttributeMappingsFromDictionary:@{
                                                  @"IdServico":@"serviceId",
                                                  @"IdFiltro":@"filterId",
                                                  @"Lido":@"read",
                                                  @"DtProcessamento":@"proccessDate",
                                                  @"Relacao":@"relation",
                                                  @"Cabecalho1":@"header",
                                                  @"Cabecalho2":@"secondHeader",
                                                  @"Texto":@"text",
                                                  @"Id":@"remoteId",
                                                  @"IdEmpresa":@"companyRemoteId",
                                                  @"IdVersao":@"versionId",
                                                  @"DtPublicacao":@"publicationDateString",
                                                  @"NomeDiario" : @"diaryName",
                                                  @"DtDisponibilizacao" : @"availableDateString",
                                                  @"NDiario" : @"diaryNumber",
                                                  @"NProcesso" : @"proccessNumber",
                                                  @"NPagina" : @"pageNumber",
                                                  @"Rodape" : @"footer"
                                                  }];

Anyone have an idea what is going on?

+4
source share
1 answer

How do you create and save this object in Realm? Keep in mind that you cannot save any property with a null value in Realm, because it will always fail.

0
source

Source: https://habr.com/ru/post/1569742/


All Articles