i’m using notification center to get notified on uitextfield finished editing, here is my code…
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textFieldChange:) name:UITextFieldTextDidEndEditingNotification object:nil];
and my function…
-(void)textFieldChange:(id)sender{
UITextField *my=(UITextField *)sender; // NOT WORKING
if([my.text length]==0){
UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"Please Fill This" message:@"This Field Can Not be Kept Empty!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil, nil];
[myAlert show];
}
}
what is wrong in this? , i feel sender is not getting type casted in textfield!
if you want to know when the Uitextfield will finish editing ,then you can check it by below code my friend..
and if you want to check it using NSNotification, then try to send your textfield object in object parameter while calling -(void)textFieldChange:(id)sender method, don’t send nil
i am not 100% sure about this but you can try,
let me know is it working or not
Happy Coding!!!!