RestKit 对象映射将一个 ID 映射为一个完全不同的负数
RestKit object mapping maps an ID as a totally different negative number
我有一个 iOS 应用程序,它使用 RestKit 从我们的服务器端 API 以 JSON 格式提取数据。我已经为此工作了大约一年,而且我以前从未见过这种情况 - 由于某种原因,RestKit 似乎将 ID 1047470 映射为 -1106。
看起来它可能是错误代码,但我不知道为什么它会显示为映射值,而不是实际错误。映射的其他 ID 工作正常,我们正在使用的许多其他实体中的所有其他 ID(据我所知)也是如此。
下面是对象映射调试日志的摘录。 (我还没有映射一些值,因为此时不需要它们。)
2015-10-21 10:27:50.577 App[13381:9422581] D restkit.object_mapping:RKMapperOperation.m:327 Found mappable collection at keyPath 'members': (
{
accountName = "Test Account Name";
memberEmail = "test##test.com";
memberFirstName = TestFirst;
memberId = 1047470;
memberLastName = "TestLast";
planId = 1;
smsConfirm = 0;
}
)
2015-10-21 10:27:50.578 App[13381:9422581] D restkit.object_mapping:RKMapperOperation.m:251 Asked to map source object {
accountName = "Test Account Name";
memberEmail = "test##test.com";
memberFirstName = TestFirst;
memberId = 1047470;
memberLastName = "TestLast";
planId = 1;
smsConfirm = 0;
} with mapping <RKEntityMapping:0x7ff3c86eaf10 objectClass=Member propertyMappings=(
"<RKAttributeMapping: 0x7ff3c86eb360 memberId => memberId>",
"<RKAttributeMapping: 0x7ff3c86ebd10 smsConfirm => smsConfirm>",
"<RKAttributeMapping: 0x7ff3c86eca20 planId => planId>"
)>
2015-10-21 10:27:50.578 App[13381:9422581] D restkit.object_mapping:RKMappingOperation.m:1159 Starting mapping operation...
2015-10-21 10:27:50.579 App[13381:9422581] D restkit.object_mapping:RKMappingOperation.m:1244 Finished mapping operation successfully...
2015-10-21 10:27:50.584 App[13381:9422581] D restkit.object_mapping:RKMapperOperation.m:433 Finished performing object mapping. Results: {
members = (
"<Member: 0x7ff3cd542a90> (entity: Member; id: 0x7ff3d3bd1ab0 <x-coredata:///Member/tC7917ADF-B44F-481D-BF96-F4F4C03B18AF3> ; data: {\n memberId = \"-1106\";\n planId = 1;\n smsConfirm = 0;\n})"
);
}
有人知道为什么会这样吗?
解决了我自己的问题 - 完全是男生错误。 memberId
是一个整数 16,这意味着 1047470 对它来说太大了。我已更改为 Integer 32,并且工作正常。菜鸟。
我有一个 iOS 应用程序,它使用 RestKit 从我们的服务器端 API 以 JSON 格式提取数据。我已经为此工作了大约一年,而且我以前从未见过这种情况 - 由于某种原因,RestKit 似乎将 ID 1047470 映射为 -1106。
看起来它可能是错误代码,但我不知道为什么它会显示为映射值,而不是实际错误。映射的其他 ID 工作正常,我们正在使用的许多其他实体中的所有其他 ID(据我所知)也是如此。
下面是对象映射调试日志的摘录。 (我还没有映射一些值,因为此时不需要它们。)
2015-10-21 10:27:50.577 App[13381:9422581] D restkit.object_mapping:RKMapperOperation.m:327 Found mappable collection at keyPath 'members': (
{
accountName = "Test Account Name";
memberEmail = "test##test.com";
memberFirstName = TestFirst;
memberId = 1047470;
memberLastName = "TestLast";
planId = 1;
smsConfirm = 0;
}
)
2015-10-21 10:27:50.578 App[13381:9422581] D restkit.object_mapping:RKMapperOperation.m:251 Asked to map source object {
accountName = "Test Account Name";
memberEmail = "test##test.com";
memberFirstName = TestFirst;
memberId = 1047470;
memberLastName = "TestLast";
planId = 1;
smsConfirm = 0;
} with mapping <RKEntityMapping:0x7ff3c86eaf10 objectClass=Member propertyMappings=(
"<RKAttributeMapping: 0x7ff3c86eb360 memberId => memberId>",
"<RKAttributeMapping: 0x7ff3c86ebd10 smsConfirm => smsConfirm>",
"<RKAttributeMapping: 0x7ff3c86eca20 planId => planId>"
)>
2015-10-21 10:27:50.578 App[13381:9422581] D restkit.object_mapping:RKMappingOperation.m:1159 Starting mapping operation...
2015-10-21 10:27:50.579 App[13381:9422581] D restkit.object_mapping:RKMappingOperation.m:1244 Finished mapping operation successfully...
2015-10-21 10:27:50.584 App[13381:9422581] D restkit.object_mapping:RKMapperOperation.m:433 Finished performing object mapping. Results: {
members = (
"<Member: 0x7ff3cd542a90> (entity: Member; id: 0x7ff3d3bd1ab0 <x-coredata:///Member/tC7917ADF-B44F-481D-BF96-F4F4C03B18AF3> ; data: {\n memberId = \"-1106\";\n planId = 1;\n smsConfirm = 0;\n})"
);
}
有人知道为什么会这样吗?
解决了我自己的问题 - 完全是男生错误。 memberId
是一个整数 16,这意味着 1047470 对它来说太大了。我已更改为 Integer 32,并且工作正常。菜鸟。