Problem with alertView clickedButtonAtIndex: crashing when i mention variables. Alternative?
I have an NSString called locationForURL1. I tracked it through my code leading into the UITextView and it didn't change at any point. I put an NSLog right before the UIAlertView's 'show' line, and even there locationForURL1 was equal to what it's supposed to be equal to - a URL.
Then the user clicks a button in the alertview and it goes straight into the clickedButtonAtIndex: part.
Here's the code from there:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"location for url1b %@", l开发者_StackOverflowocationForURL1);
if ((alertView.tag <= 3) && (alertView.tag >= 1)) {
if (buttonIndex == 1) {
NSLog(@"location for url1 %@", locationForURL1);
It doesn't even make it to the 2nd NSLog, it crashes at the first. I've replaced these NSLogs with ones simply saying 'test' so i know it's only happening because of that.
I'm unsure how to solve this problem though? Just the mention of locationForURL1 is crashing it suddenly.
Are there any alternatives to UIAlertView, maybe an open source project to make something similar but better? It's seems very touch and go, from past experience.
It looks like the NSString is an ivar...is your accessor set to nonatomic? Are you calling the setter? (You should...for both)
I guess you should do self.locationForURL1=aURL
instead of locationForURL1=aURL
somewhere else. UIAlertView has nothing to do with the crash.
精彩评论