title: EXC_BAD_ACCESS again
body: <p>I'm building(trying ... )  an iPhone application.
  My first user story is a login View who send the credential of the user to a webservice (WCF).
  The communication process with the web service is working fine without any problem.
  But I have to deserialize the message coming form it. For that I used the NSXMLParser to create the message Object who contain the response of the service. This when the problem begin :</p>
  
  <p>This is the Message parser :</p>
  
  <h2>.h</h2>
  
  <pre><code>@interface MessageParser : NSObject  &lt;NSXMLParserDelegate&gt; {
      NSMutableString* currentProperty;
      Message* message;
  }
  
  @property (nonatomic, retain) NSMutableString* currentProperty;
  @property (nonatomic, retain) Message* message;
  
  - (void)parseMessageData:(NSData *)data parseError:(NSError **)err;
  
  @end
  </code></pre>
  
  <h2>.m</h2>
  
  <pre><code>@implementation MessageParser
  
  @synthesize message, currentProperty;
  
  - (void)parseMessageData:(NSData *)data parseError:(NSError **)err 
  {
      NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
  
      [parser setDelegate:self]; 
      [parser setShouldProcessNamespaces:NO]; 
      [parser setShouldReportNamespacePrefixes:NO]; 
      [parser setShouldResolveExternalEntities:NO]; 
  
      [parser parse];
  
      if (err &amp;&amp; [parser parserError]) {
          *err = [parser parserError];
      }
  
      [parser release];
  }
  
  -(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
  {
      if(qName){
          elementName = qName;
      }
  
      if([elementName isEqualToString:@"Message"]){
          self.message = [[Message alloc] init];
      }
      else if( [elementName isEqualToString:@"body"] || [elementName isEqualToString:@"code"] || [elementName isEqualToString:@"error"]){
          currentProperty = [NSMutableString string];
      }
  }
  
  -(void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
  {
      if(qName){
          elementName = qName;
      }
      if(message){
          if([elementName isEqualToString:@"body"]){
              self.message.messageBody = currentProperty;
          }
          else if([elementName isEqualToString:@"error"]){
              self.message.error = currentProperty;
          }
          else if([elementName isEqualToString:@"code"]){
  
              NSNumberFormatter * f = [[NSNumberFormatter alloc] init];            
              [f setNumberStyle:NSNumberFormatterDecimalStyle];
  
              self.message.messageCode = [f numberFromString:currentProperty];
              [f release];
          }
      }
  
      self.currentProperty = nil;
  }
  
  - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)foundedCharacters
  {
      if (self.currentProperty) {
          [currentProperty appendFormat:@"%@", foundedCharacters];
      }
  }
  </code></pre>
  
  <p>this is the Login action :</p>
  
  <pre><code>- (IBAction)didLogin:(id)sender 
  {
      NSData* receivedData;
      NSError* parserError;
      NSError* error;
  
      receivedData = [[ServiceClient PerformLogin:txtLogin.text withPassword:txtPassword.text error:error] retain];    
      MessageParser* messageParser = [[MessageParser alloc] init];
  
      Message* msg;    
      [messageParser parseMessageData:receivedData parseError:&amp;parserError];
  
      msg = [messageParser.message retain];
  
      if(msg &amp;&amp; !msg.error){        
  
          UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Login Service Response" message:msg.messageBody delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
          [alert show];
          [alert release];
      }
      else if(msg.error){
          UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error" message:msg.error delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
          [alert show];
          [alert release];
      }
      else if(!msg){
          UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Enable to contact the Athentication service." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
          [alert show];
          [alert release];
      }
  }
  </code></pre>
  
  <p>the Message Object :</p>
  
  <pre><code>@interface Message : NSObject{
      NSString* messageBody;
      NSNumber* messageCode;
      NSString* error;   
  }
  
  @property (retain, nonatomic) NSString* messageBody;
  @property (retain, nonatomic) NSNumber* messageCode;
  @property (retain, nonatomic) NSString* error;
  
  @end
  
  @implementation Message
  @synthesize error, messageBody, messageCode;
  
  @end
  </code></pre>
  
  <p>So what is happened ? 
  Some time when is clik login it show me the alert then xcode throw me EXC_BAD_ACCESS error in the main.m in this code :</p>
  
  <pre><code>@autoreleasepool {
      return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
  }
  </code></pre>
  
  <p>And some time when I click login it throw me the same error directly.</p>
  
  <p>What's wrong with my code ? Do I have some memory management problems ? where ?</p>
  
  <p>Thank you.</p>