title: NSArray stringByAppendingString
body: <p>I need to append String by adding an array of Suit to an array of Rank, something like this.</p>
  
  <pre><code>-(NSString *)contents {
      return [NSString stringWithFormat:@"%d %@", self.rank, self.suit];
  }
  </code></pre>
  
  <p>The correct code is written as below. I don't understand the code.
  Does NSString return just 1 String or an array of String? 
  What does the code [PlayingCard validRanks] do? 
  Why does rankStr have to use [self.rank]? Why can't it use validRanks and validSuit directly?</p>
  
  <pre><code>-(NSString *)contents {
  
      NSArray *rankStr = [PlayingCard validRanks];
  
      return [rankStr [self.rank] stringByAppendingString: self.suit];
  }   
  </code></pre>
  
  <p>the rest of the code is:</p>
  
  <pre><code>#import "PlayingCard.h"
  
  @implementation PlayingCard
  
  
  
  -(NSString *)contents {
  
      NSArray *rankStr = [PlayingCard validRanks];
  
      return [rankStr [self.rank] stringByAppendingString: self.suit];
  }   
  
  
  
  @synthesize suit = _suit;
  
  -(void)setSuit: (NSString *)suits {
      if ([[PlayingCard validSuits] containsObject:suits]) {
          _suit = suits;
      }
  }
  
  -(NSString *) suit {
       return _suit ? _suit : @"?";
  }
  
  
  
  @synthesize rank = _rank;
  
  
  -(void)setRank: (NSUInteger)ranks {
      if (ranks &lt;= [PlayingCard maxRank]) {
           _rank = ranks; }
  }
  
  
  +(NSUInteger) maxRank {
      return [self validRanks].count - 1;
  } 
  
  
  +(NSArray *) validSuits {
      return @[@"♥", @"♦", @"♠", @"♣"];
  }
  
  
  +(NSArray *) validRanks {
      return @[@"?", @"A", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"J", @"Q", @"K"];
  }
  
  
  @end
  </code></pre>
  
  <p>Thank you. </p>