[英]“EXC_BAD_ACCESS” in Xcode
在运行iPhone模拟时,我在Xcode中显示“ EXC_BAD_ACCESS”的错误
代码如下:
测试
@interface Test : UIViewController
{
int iWeight;
}
end
测试
@implementation Test
- (void)viewDidLoad
{
iWeight = 15;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
**NSLog(@"integer Number is :%@", iWeight); // error occur**
}
如果我单击UIAlertView的按钮,则Xcode会在该代码处发生“ EXC_BAD_ACCESS”错误
我不知道为什么该代码会发生错误。 帮我。
尝试NSLog(@"integer Number is :%d", iWeight);
yes, try this
NSLog(@"wieght is %d",iweight);
%d type specifier for int iweight;
and also set property in .h file and synthesize it in .m file.
if it dont work then try this
remove your alertview method
write this
// .h file
-(IBAction)buttonClicked;
// .m file
-(IBAction)buttonClicked
{
NSLog(@"weight %d",iweight");
}
right click of button and assign TouchUpInside to buttonClicked method.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.