Skip to content

Instantly share code, notes, and snippets.

View infolock's full-sized avatar
👨‍👩‍👦‍👦
nqdq

infolock infolock

👨‍👩‍👦‍👦
nqdq
View GitHub Profile
@interface NSObject (MHOverride)
/*
* Dynamically overrides the specified method on this particular instance.
*
* The block's parameters and return type must match those of the method you
* are overriding. However, the first parameter is always "id _self", which
* points to the object itself.
*
//
// ARSearchBar.h
// Artsy Folio
//
// Created by orta therox on 18/04/2012.
// Released under The MIT License
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) 2012 http://art.sy. All rights reserved.
//
@infolock
infolock / CurrencyExample.mm
Last active December 17, 2015 23:58
UITextField delegate method shouldChangeCharactersInRange for allowing a valid currency value with the format of $x.xx. The following rules are enforced: 1) The value within the textField begins with a $ 2) Allows a decimal to be inserted only when there is 1 or more integers already in the field 3) Prevents more than 1 decimal to be inserted 4)…
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSString *textValue = textField.text;
if(textValue.length > 0 && string.length > 0) {
NSRange dotRange = [textValue rangeOfString:@"."];
BOOL isDot = [string isEqualToString:@"."];
if(isDot) {
return (dotRange.length == 0);
@infolock
infolock / dismissKeyboard.h
Last active December 17, 2015 05:09
Different ways one can dismiss a keyboard by tapping the background
@interface someController : UIViewController
@property (nonatomic, weak) UITextField *someTextField;
-(void)dismissKeyboard;
@end