I think you should do something like this:
1) when you creating views for points (firstPasscodeDigitTextfield, etc.), set tag to them: 0,1,2,3
2) get whole string value from passwordTextField when she changed
3) get length of the string
4) implement function:
-(void)setNpointsToView:(NSUInteger)n
{
//getting your views and set point to them
for (int i = 0; i < n; ++i)
{
[[self.view viewWithTag:i] setText: @"\u25cf"];
}
//set "" to other views
for (int i = n; i < 3; ++i)
{
[[self.view viewWithTag:i] setText" @""];
}
}
5) call this function every time you change text in passwordTextField with ((length of the string) - 1) as parameter
6) Implement:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField == passcodeTextfield)
{
NSString *passcode = [textField.text stringByReplacingCharactersInRange:range withString:string];
if (passcode.length > 3)
return NO;
}
}