title: When I am appending a NSString with another NSstring it Gives me an error "EXC BAD ACCESS"?
body: <p>Solved....Check at bottom of Body..</p>
  
  <p>I am using XCODE 4</p>
  
  <p>I have an Money Calculator Application in which I have to press the digit buttons and I have to see it on the TextLabel.</p>
  
  <p>Format like : "$ 500"</p>
  
  <p>So for $ I am appending it..</p>
  
  <p>The method works twice well but the third time it crashes..</p>
  
  <p>Rest if you see the code you will have an Idea.</p>
  
  <p>In my Application I have Three String variables...</p>
  
  <p>-(void)viewDidLoad
  {   </p>
  
  <pre><code>  current =[[NSString alloc] retain];
  
    current=[[NSUserDefaults standardUserDefaults] valueForKey:@"Total"]];
  
  
  
    NSString *newCurrent=[NSString stringWithFormat:@"$ %@",current];
  
    textViewer.text=newCurrent;
  
   NSLog(@"%@",current);
  </code></pre>
  
  <p>}</p>
  
  <p>-(IBAction)buttonDigitPressed:(id)sender {</p>
  
  <pre><code>NSString *str= (NSString* )[sender currentTitle];
  
  //NSLog(@"1 The Value Of String %@",str);
  
  NSLog(@"Befor Appending %@",current);
  
  
  if([current isEqualToString:@"0"])
  {
      current =  str;
  }
  else 
  {
  
     current = [current stringByAppendingString:str];
  
      NSLog(@"After Appending %@",current);
  
  }
  
  
  NSString *newCurrent=@"$ ";
  
  newCurrent = [newCurrent stringByAppendingString:current];
  
  textViewer.text= newCurrent;  
  </code></pre>
  
  <p>}
  Error is 1st time it is working fine but </p>
  
  <blockquote>
    <p>when I call it second time, current is Pointing to some Standard Time
    formatted value, some time it points to some file name value,</p>
  </blockquote>
  
  <p>Error is: EXC BAD ACCESS<br>
  <strong>When I am doing it without newCurrent means without appending a letter it works fine.</strong></p>
  
  <p>-------SOLVED----------------
  Every thing is Ok with My Code I just have to right <strong>[current retain];</strong> where ever I am appending the String to the current.</p>
  
  <p>As I was receiving the error EXC BAD ACCESS means I was referring to the Object which was released previously.
  So, I have retained the Object instead. </p>