override isEqual Objective-C -


my class

@interface sample:nsobject{     double x;     double y;  } @property double x;  @property double y;  -(sample *)initwithx: (double)x andy:(double) y;   @implementation  @synthesize x,y  -(sample *) initwithx: (double)x andy:(double)y{      self = [super init];      if(self)      {        self.x = x;        self.y = y;       }      return self;  }  -(bool)isequal:(id)other{   if(other == self)    return yes;  if(!other || ![other iskindofclass:[self class]])    return no;  return [self isequaltosample:other];   }   -(bool)isequaltosample:(sample *) other{   if(self == other)        return yes;   if (!([self x] ==[other x]))     return no;   if (!([self y] ==[other y]))       return no;     return yes; } 

at

return [self isequaltosample:other]; shows warning: 'sample' maynot respont '-isequaltosample'. return makes integer pointer without cast.

unrelated warning, when overriding -isequal: must override hash such if [a isequal: b] [a hash] == [b hash].


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -