realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

isEqual: on RLMArrays returns false, even if objects are the same

Open peterpaulis opened this issue 7 years ago • 1 comments

Goals

Expected Results

When all objects in array are equal isEqual should return YES

Actual Results

(lldb) p [sself.profile.demandCategories isEqual:tmpProfile.demandCategories]
(BOOL) $1 = NO
(lldb) po tmpProfile.demandCategories
RLMArray <0x17045fcb0> (
	[0] DemandCategory {
		demandCategoryID = 25;
		title = Počítače a IT;
		type = 1;
	},
	[1] DemandCategory {
		demandCategoryID = 15;
		title = Strechár;
		type = 0;
	},
	[2] DemandCategory {
		demandCategoryID = 21;
		title = Autoservis, pneuservis;
		type = 0;
	},
	[3] DemandCategory {
		demandCategoryID = 7;
		title = Elektrikár;
		type = 0;
	},
	[4] DemandCategory {
		demandCategoryID = 2;
		title = Iná služba;
		type = 1;
	},
	[5] DemandCategory {
		demandCategoryID = 20;
		title = Handmade;
		type = 0;
	}
)

(lldb) po sself.profile.demandCategories
RLMArray <0x1702fcc80> (
	[0] DemandCategory {
		demandCategoryID = 25;
		title = Počítače a IT;
		type = 1;
	},
	[1] DemandCategory {
		demandCategoryID = 15;
		title = Strechár;
		type = 0;
	},
	[2] DemandCategory {
		demandCategoryID = 21;
		title = Autoservis, pneuservis;
		type = 0;
	},
	[3] DemandCategory {
		demandCategoryID = 7;
		title = Elektrikár;
		type = 0;
	},
	[4] DemandCategory {
		demandCategoryID = 2;
		title = Iná služba;
		type = 1;
	},
	[5] DemandCategory {
		demandCategoryID = 20;
		title = Handmade;
		type = 0;
	}
)

Steps to Reproduce

What are steps we can follow to reproduce this issue?

Code Sample

tmpProfile is not saved in Realm, but the demandCategories are fetched from Realm and inserted

        Profile * tmpProfile = [Profile new];
        [tmpProfile.demandCategories addObjects:selected];

Compare

[self.profile.demandCategories isEqual:tmpProfile.demandCategories]

Version of Realm and Tooling

Realm version: 2.0.3

Xcode version: 8.0

iOS/OSX version: 10.0.1

Dependency manager + version: ?

peterpaulis avatar Nov 15 '16 15:11 peterpaulis