iphone - Fires EXC_BAD_ACCESS -
hi trying implement captcha functionality. following code, have used generating random word:
-(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<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]; }
the problem variable randomword. can access variable inside method named "createcaptchaword". there function save information entered. in method, when tried access variable "randomword", got exception exc_bad_access. enabled nszombie. got following message in console:
-[cfstring respondstoselector:]: message sent deallocated instance 0x4656c10
can me solve issue.
regards, sreelash
you have retain value assigned randomword
variable either using retain
or setter method (when it's property) self.randomword = ...
Comments
Post a Comment