Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad access when using [alert setButtonTitles:NULL]; #32

Closed
TomDoes opened this issue Jan 8, 2014 · 7 comments
Closed

Bad access when using [alert setButtonTitles:NULL]; #32

TomDoes opened this issue Jan 8, 2014 · 7 comments

Comments

@TomDoes
Copy link

TomDoes commented Jan 8, 2014

I'm using a custom alertView to indicate the loading of a UIWebView but it crashes with a bad access message. Without the setButtonTitles line it works fine.

-(void)webViewDidStartLoad:(UIWebView *)webView
{
alert = [[CustomIOS7AlertView alloc]initWithParentView:self.view];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0,10,240,100)];
[spinner startAnimating];
UIView *demoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 100)];
UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(0, -30, 240, 100)];

[demoView addSubview:spinner];
[demoView addSubview:label];
[alert setContainerView:demoView];
[alert setButtonTitles:NULL];

[alert show];

}

@wimagguc
Copy link
Owner

wimagguc commented Jan 9, 2014

thanks @TomDoes,
which xcode / ios version are you using? is there a difference passing NULL or nil object?
(also, i've updated the setButtonTitles function with some more defensive code, which should handle null pointers a bit better. would be fun to chase this down though.)

@TomDoes
Copy link
Author

TomDoes commented Jan 9, 2014

Hey this is in xcode 5 ios 7.0.x tried it on devices and simulator. I figured it might have something to with NULL or nil, however both result in a bad access. I tested your more defensive code and it doesn't fix the BAD ACCESS When i remove the setButtons line it works fine again, but with a close button.

@wimagguc
Copy link
Owner

wimagguc commented Jan 9, 2014

getting weirder. if you want, you can try to change the CustomIOS7AlertView's init function to be

buttonTitles = nil;

(instead of buttonTitles = @[@"Close"];), that would do the same as setting it to nil with setButtonTitles. perhaps that gives you more insight in the problem. if not, feel free to share some more code, i'll try to look at it. in private, you can find me on twitter by the @wimagguc handle.)

@TomDoes
Copy link
Author

TomDoes commented Jan 9, 2014

Well, setting buttonTitles = nil in the init fixes the bad access problem.

@wimagguc
Copy link
Owner

wimagguc commented Jan 9, 2014

is it an arc project?
in any ways, we are using @sythesize for the getters/setters - so if a project clean doesn't solve your problem, please feel free to send some more code. (i tried to run the one you have in place, and it works all fine in emulator and on the device as well.)

@TomDoes
Copy link
Author

TomDoes commented Jan 9, 2014

Yes, it's an arc project. It's weird, for now i'll leave it like this. If I encounter similar problems later on, or the source of the bad access i'll let you know.

Thanks for looking into it!

@wimagguc
Copy link
Owner

wimagguc commented Jan 9, 2014

haha no worries. i'll close this for now, but just fire up a new ticket if you have more details on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants