FourLines.m
上传用户:jjjjag8
上传日期:2017-04-17
资源大小:1443k
文件大小:2k
源码类别:

iPhone

开发平台:

MultiPlatform

  1. //
  2. //  FourLines.m
  3. //  Persistence
  4. //
  5. //  Created by Jeff LaMarche on 7/29/08.
  6. //  Copyright 2008 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "FourLines.h"
  9. @implementation FourLines
  10. @synthesize field1;
  11. @synthesize field2;
  12. @synthesize field3;
  13. @synthesize field4;
  14. #pragma mark NSCoding
  15. - (void)encodeWithCoder:(NSCoder *)encoder
  16. {
  17. [encoder encodeObject:field1 forKey:kField1Key];
  18. [encoder encodeObject:field2 forKey:kField2Key];
  19. [encoder encodeObject:field3 forKey:kField3Key];
  20. [encoder encodeObject:field4 forKey:kField4Key];
  21. }
  22. - (id)initWithCoder:(NSCoder *)decoder
  23. {
  24. if (self = [super init])
  25. {
  26. self.field1 = [decoder decodeObjectForKey:kField1Key];
  27. self.field2 = [decoder decodeObjectForKey:kField2Key];
  28. self.field3 = [decoder decodeObjectForKey:kField3Key];
  29. self.field4 = [decoder decodeObjectForKey:kField4Key];
  30. }
  31. return self;
  32. }
  33. #pragma mark -
  34. #pragma mark NSCopying
  35. // The implementation of copyWithZone on page 346 is incorrect. Either this one,
  36. // or the one commented out below are correct.
  37. - (id)copyWithZone:(NSZone *)zone
  38. {
  39. FourLines *copy = [[[self class] allocWithZone: zone] init];
  40. NSString *field1Copy = [self.field1 copy];
  41. copy.field1 = field1Copy;
  42. [field1Copy release];
  43. NSString *field2Copy = [self.field2 copy];
  44. copy.field2 = field2Copy;
  45. [field2Copy release];
  46. NSString *field3Copy = [self.field3 copy];
  47. copy.field3 = field3Copy;
  48. [field3Copy release];
  49. NSString *field4Copy = [self.field4 copy];
  50. copy.field4 = field4Copy;
  51. [field4Copy release];
  52. return copy;
  53. }
  54. //- (id)copyWithZone:(NSZone *)zone
  55. //{
  56. // FourLines *copy = [[[self class] allocWithZone: zone] init];
  57. // copy.field1 = [[self.field1 copy] autorelease];
  58. // copy.field2 = [[self.field2 copy] autorelease];
  59. // copy.field3 = [[self.field3 copy] autorelease];
  60. // copy.field4 = [[self.field4 copy] autorelease];
  61. // return copy;
  62. //}
  63. @end