You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZXRSSExpandedRow.m 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXRSSExpandedRow.h"
  17. @implementation ZXRSSExpandedRow
  18. - (id)initWithPairs:(NSArray *)pairs rowNumber:(int)rowNumber wasReversed:(BOOL)wasReversed {
  19. if (self = [super init]) {
  20. _pairs = [NSArray arrayWithArray:pairs];
  21. _rowNumber = rowNumber;
  22. _wasReversed = wasReversed;
  23. }
  24. return self;
  25. }
  26. - (BOOL)isReversed {
  27. return self.wasReversed;
  28. }
  29. - (BOOL)isEquivalent:(NSArray *)otherPairs {
  30. return [self.pairs isEqualToArray:otherPairs];
  31. }
  32. - (NSString *)description {
  33. return [NSString stringWithFormat:@"{%@}", self.pairs];
  34. }
  35. /**
  36. * Two rows are equal if they contain the same pairs in the same order.
  37. */
  38. - (BOOL)isEqual:(id)object {
  39. if (![object isKindOfClass:[ZXRSSExpandedRow class]]) {
  40. return NO;
  41. }
  42. ZXRSSExpandedRow *that = (ZXRSSExpandedRow *)object;
  43. return [self.pairs isEqual:that.pairs] && (self.wasReversed == that.wasReversed);
  44. }
  45. - (NSUInteger)hash {
  46. return self.pairs.hash ^ @(self.wasReversed).hash;
  47. }
  48. @end