简体   繁体   中英

“EXC_BAD_ACCESS” in Xcode

while run iphone simulation, I show the error for "EXC_BAD_ACCESS" in Xcode

code is below :

Test.h

 @interface Test : UIViewController
 {
   int iWeight;
 }

end

Test.m

@implementation Test

- (void)viewDidLoad 
{
   iWeight = 15; 
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{

    **NSLog(@"integer Number is :%@", iWeight);  // error occur**

}

If i click the Button of UIAlertView, Xcode occur "EXC_BAD_ACCESS" error at that code

I don't know why that code occur error. help me.

尝试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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM