«EXC_BAD_ACCESS» в Xcode - PullRequest
       1

«EXC_BAD_ACCESS» в Xcode

0 голосов
/ 11 октября 2011

при запуске имитации iphone, я показываю ошибку для «EXC_BAD_ACCESS» в Xcode

код ниже:

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**

}

Если я нажимаю кнопку UIAlertView, в этом коде возникает ошибка «EXC_BAD_ACCESS» с кодом

Я не знаю, почему возникает этот код ошибки.помоги мне.

Ответы [ 2 ]

3 голосов
/ 11 октября 2011

Попробуйте NSLog(@"integer Number is :%d", iWeight);

0 голосов
/ 11 октября 2011
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.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...