title: EXC_BAD_ACCESS code=2 error on custom class initialization in Xcode
body: <p>I'm attempting to initialize a custom class in my view controller to manage the data. Unfortunately the app crashes during the loading. I'm running Xcode 5.02 with the lldb debugger. The error I get is </p>
  
  <pre><code>Thread 1: EXC_BAD_ACCESS (code=2, address=0xbf7ffffc)
  </code></pre>
  
  <p>The error shows up on the first line (-(void)...) of the function </p>
  
  <pre><code>    -(void)setDateOfErgPiece:(NSDate *)date
  {
      self.dateOfErgPiece = date;
  
      if(self.dateOfErgPiece) {
          // Date Formatter. So Date is displayed correctly
          NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
          [dateFormatter setDateStyle:NSDateFormatterShortStyle];
          [dateFormatter setTimeStyle:NSDateFormatterNoStyle];
          // Set value
          self.dateOfErgPieceString = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:self.dateOfErgPiece]];
      }
  
  }
  </code></pre>
  
  <p>That method is called when the object is initialized by </p>
  
  <pre><code>-(id)initWithDate:(NSDate *)date
  {
      self = [super init];
  
      if(self) {
          [self setDateOfErgPiece:date];
      }
  
      return self;
  }
  </code></pre>
  
  <p>The (NSDate *)date value in the above init method is received from this method</p>
  
  <pre><code>-(ErgNewDataEntryLogic *)ergPieceData {
      if(!_ergPieceData) _ergPieceData = [[ErgNewDataEntryLogic alloc] initWithDate:[NSDate date]];
      return _ergPieceData;
  }
  </code></pre>
  
  <p>What is causing this error? If you need more information I'd be happy to provide it. Thank you so much!</p>