/Tests/Person.m

http://github.com/bhatti/OCActiveObjects · Objective C · 69 lines · 46 code · 16 blank · 7 comment · 7 complexity · ce37e6549c8d6f16ba4380118aa7ca83 MD5 · raw file

  1. //
  2. // Person.m
  3. // PlexLotto
  4. //
  5. // Created by shahzad bhatti on 6/6/09.
  6. // Copyright 2009 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "Person.h"
  9. @implementation Person
  10. @synthesize name;
  11. @synthesize age;
  12. @synthesize rank;
  13. @synthesize votes;
  14. @synthesize sex;
  15. @synthesize income;
  16. @synthesize active;
  17. @synthesize flags;
  18. @synthesize rating;
  19. @synthesize birthdate;
  20. - (BOOL)isEqual:(id)other {
  21. if (other == self)
  22. return YES;
  23. if (!other || ![other isKindOfClass:[self class]])
  24. return NO;
  25. return [self isEqualToPerson:other];
  26. }
  27. - (BOOL)isEqualToPerson:(Person *)aPerson {
  28. if (self == aPerson)
  29. return YES;
  30. if (![(id)[self name] isEqual:[aPerson name]])
  31. return NO;
  32. return YES;
  33. }
  34. - (NSUInteger)hash {
  35. NSUInteger hash = 0;
  36. hash += [[self name] hash];
  37. return hash;
  38. }
  39. - (NSString *)description {
  40. return [NSString stringWithFormat:@"id %@, name %@, age %d, rank %d, votes %d, sex %c, income %f, active %d, flags %d, rating %@, birthdate %@",
  41. self.objectId, self.name, self.age, self.rank, self.votes, self.sex, self.income, self.active, self.flags, self.rating, self.birthdate];
  42. }
  43. - (void) dealloc {
  44. [birthdate release];
  45. [super dealloc];
  46. }
  47. + (NSString *) getTableName {
  48. return @"persons";
  49. }
  50. + (NSString *) getDatabaseName {
  51. return @"personsdb";
  52. }
  53. @end