title: Retain-Release in Objective-C
body: <p>I am new to Objective-C and I am confused about this retain-release thing. Are parameters retained automatically? Do I need to release them?</p>
  
  <p>Here is my code. Did I do the retain-release thing (and everything else) correctly?</p>
  
  <pre><code>#import "ACStringTokenizer.h"
  
  
  @implementation ACStringTokenizer
  
  - (id)init
  {
      self = [super init];
      if (self) {
          // Initialization code here.
      }
  
      return self;
  }
  
  - (id)initWithStr:(NSString *)theString
  {
      self = [super init];
      if (self) {
          string = [theString retain];
          delimiters = @" ";
          doesReturnDelims = NO;
      }
  
      return self;
  }
  
  - (id)initWithStr:(NSString *)theString andDelims:(NSString *)theDelimiters
  {
      self = [super init];
      if (self) {
          string = [theString retain];
          delimiters = [theDelimiters retain];
          doesReturnDelims = NO;
      }
  
      return self;
  }
  
  - (id)initWithStr:(NSString *)theString andDelims:(NSString *)theDelimiters andDoesReturnDelims:(BOOL)returnDelims
  {
      self = [super init];
      if (self) {
          string = [theString retain];
          delimiters = [theDelimiters retain];
          doesReturnDelims = returnDelims;
      }
  
      return self;
  }
  
  - (int)countTokens
  {
      return numberOfTokens;
  }
  
  - (BOOL)hasMoreTokens
  {
      return ![queue isEmpty];
  }
  
  - (NSString *)nextToken
  {
      return [queue remove];
  }
  
  - (void)dealloc
  {
      [string release];
      [delimiters release];
      [queue release];
  
      [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>P.S. How do I make init with no parameters invalid?</p>