Fires EXC_BAD_ACCESS
<p>Hi I am trying to implement Captcha functionality. The following code, i have used for generating random word:</p>

<pre><code>-(void) createCaptchaWord{
        lettersArray = [[NSMutableArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z", nil];
        randomWord = @"";

    for(NSUInteger i=0;i&lt;5;i++){
        NSUInteger randomNumber = arc4random()%[lettersArray count];
        randomWord = [randomWord stringByAppendingString:[lettersArray objectAtIndex:randomNumber]];
        //randomWord = [NSString stringWithFormat:@"%@%@",randomWord,[lettersArray objectAtIndex:randomNumber]];
    }

    NSString *captchaUrl = [NSString stringWithFormat:@"%@%@",CommonFunctions.captchaImgUrl,randomWord];
    UIImage *captchaImage = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:captchaUrl]]];

    [captchaImgView setImage:captchaImage];
}
</code></pre>

<p>The problem is with the variable randomWord. I can access this variable inside the method named "createCaptchaWord". There is another function to save all the information entered. In that method, when i tried to access the variable "randomWord", I got the exception EXC_BAD_ACCESS. Then i enabled NSZombie. Thus i got the following message in the console:</p>

<p><strong>-[CFString respondsToSelector:]: message sent to deallocated instance 0x4656c10</strong></p>

<p>Can anyone help me to solve this issue.</p>

<p>Regards,
Sreelash</p>
