SkillAgentSearch skills...

HMFCurrencyFormatter

A piece of code that will automatically format a uitextfield with a numberpad to behave like an ATM

Install / Use

/learn @Hackmodford/HMFCurrencyFormatter
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

HMFCurrencyFormatter

A piece of code that will automatically format a uitextfield with a numberpad to behave like an ATM

Here's an example

Create a property for the formatter

@property (nonatomic, retain) HMFCurrencyFormatter *priceFormatter;

In the viewDidLoad make sure to initalize

self.priceFormatter = [[HMFCurrencyFormatter alloc] init];

Wherever you setup your textfield set the priceFormatter as the delegate

myTextField.delegate = self.priceFormatter;

To automatically add the "+/-" button to the numberpad (iphone only) call this method.

[self.priceFormatter startWatchingForKeyboardFromTextField:myTextField];

(optional) if you want to handle the delegation yourself you can do this also.

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
 
 textField.text = [HMFCurrencyFormatter formatTextField:textField withReplacementString:string]
 return NO;
}

If you have a textfield in a UIAlertView be sure to call "startWatchingFor..." everytime you show the alert.

You're done!

View on GitHub
GitHub Stars26
CategoryDevelopment
Updated2y ago
Forks6

Languages

Objective-C

Security Score

60/100

Audited on Aug 27, 2023

No findings