3

individualPercUpdated is called on UIControlEventEditingDidEnd and checkInitialValue is callled on UIControlEventEditingDidBegin. My prog crash on line if(!([initialValue isEqualToString:textField.text])) by giving warning Exec Bad Access

- (void)viewDidLoad
{
    [super viewDidLoad];
    initialValue=[[NSString alloc] init];
}

-(void) individualPercUpdated:(UITextField *)textField{

    if(initialValue!=nil){
        if(!([initialValue isEqualToString:textField.text])){
            initialValue=textField.text;
            NSLog(@"%@",textField.text);
        }
    }

    else{
        NSLog(@"%@",textField.text);
    }
}

-(void) checkInitialValue:(UITextField *)textField{
        initialValue=textField.text;
    }

}
rishi
  • 11,779
  • 4
  • 40
  • 59
Idrees Ashraf
  • 1,363
  • 21
  • 38

1 Answers1

8

Replace everywhere you use the instance variable with property and access it though it and you will not have any problems with the memory management.

@property (nonatomic, copy) NSString *initialValue;
...
@synthesize initialValue = _initialValue;
....
//Access with:
self.initialValue = @"something";
graver
  • 15,183
  • 4
  • 46
  • 62