Inscrutable Swift compiler error when comparing two object arrays -


i'm trying compare 2 object arrays this:

if oneobjectarray != anotherobjectarray {    // ... stuff } 

however following less helpful compiler error:

binary operator '!=' cannot applied operands of type '[mymodelobject]' , '[(mymodelobject)]'`

the compiler error points first operand in equality check.

i think problem have not made myobectmodel equatable.

in order check equality of 2 arrays of myobjectmodel need able check equality of 2 myobjectmodel objects.

to need following...

extension myobjectmodel: equatable {}  // top level function func ==(lhs: myobjectmodel, rhs: myobjectmodel) -> bool {     // check if objects equal here...     return lhs.name == rhs.name } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -