├── Example ├── Example │ ├── AppDelegate.h │ ├── main.m │ ├── NGMaskedTextField.h │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── ViewController.h │ ├── Info.plist │ ├── ViewController.m │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── AppDelegate.m │ └── NGMaskedTextField.m ├── ExampleTests │ ├── Info.plist │ └── ExampleTests.m ├── ExampleUITests │ ├── Info.plist │ └── ExampleUITests.m └── Example.xcodeproj │ └── project.pbxproj ├── Classes ├── NGMaskedTextField.h └── NGMaskedTextField.m ├── LICENSE.md ├── .gitignore └── README.md /Example/Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Example/Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/Example/NGMaskedTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // NGMaskedTextField.h 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NGMaskedTextField : UITextField 12 | 13 | @property (nonatomic, strong) NSString *inputString; 14 | @property (nonatomic, strong) NSString *maskString; 15 | @property (nonatomic, strong) NSString *defaultCharacterMask; 16 | @property (nonatomic, strong) NSString *defaultNumberMask; 17 | @property (nonatomic, strong) NSString *defaultFill; 18 | 19 | - (BOOL)shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; 20 | 21 | @end 22 | 23 | 24 | -------------------------------------------------------------------------------- /Classes/NGMaskedTextField.h: -------------------------------------------------------------------------------- 1 | // 2 | // NGMaskedTextField.h 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NGMaskedTextField : UITextField 12 | 13 | @property (nonatomic, strong) NSString *inputString; 14 | @property (nonatomic, strong) NSString *maskString; 15 | @property (nonatomic, strong) NSString *defaultCharacterMask; 16 | @property (nonatomic, strong) NSString *defaultNumberMask; 17 | @property (nonatomic, strong) NSString *defaultFill; 18 | 19 | - (BOOL)shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; 20 | - (NSString *)executeMaskOnInput; 21 | 22 | @end 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/ExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/ExampleUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Example/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NGMaskedTextField.h" 11 | 12 | @interface ViewController : UIViewController 13 | 14 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *phoneNumberTextField; 15 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *dateTextField; 16 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *hourTextField; 17 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *dateAndHourTextField; 18 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *CVCNumberTextField; 19 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *expireDateTextField; 20 | @property (strong, nonatomic) IBOutlet NGMaskedTextField *usStateCodeTextField; 21 | 22 | 23 | @end 24 | 25 | -------------------------------------------------------------------------------- /Example/ExampleTests/ExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleTests.m 3 | // ExampleTests 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ExampleTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Ngier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Example/Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Example/ExampleUITests/ExampleUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleUITests.m 3 | // ExampleUITests 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ExampleUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation ExampleUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # Xcode 46 | .DS_Store 47 | xcuserstate 48 | build/ 49 | *.pbxuser 50 | !default.pbxuser 51 | *.mode1v3 52 | !default.mode1v3 53 | *.mode2v3 54 | !default.mode2v3 55 | *.perspectivev3 56 | !default.perspectivev3 57 | *.xcworkspace 58 | !default.xcworkspace 59 | xcuserdata 60 | profile 61 | *.moved-aside 62 | DerivedData 63 | .idea/ 64 | # Pods - for those of you who use CocoaPods 65 | Pods 66 | -------------------------------------------------------------------------------- /Example/Example/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | //set text fields' masks 21 | [self.phoneNumberTextField setMaskString:@"(###) ###-####"]; 22 | [self.dateTextField setMaskString:@"##/##/####"]; 23 | [self.hourTextField setMaskString:@"##:##:##"]; 24 | [self.dateAndHourTextField setMaskString:@"##/##/## ##:##:##"]; 25 | [self.CVCNumberTextField setMaskString:@"###"]; 26 | [self.expireDateTextField setMaskString:@"##/##"]; 27 | [self.usStateCodeTextField setMaskString:@"??"]; 28 | 29 | //set delagete of text fileds as 'self' 30 | [self.phoneNumberTextField setDelegate:self]; 31 | [self.dateTextField setDelegate:self]; 32 | [self.hourTextField setDelegate:self]; 33 | [self.dateAndHourTextField setDelegate:self]; 34 | [self.CVCNumberTextField setDelegate:self]; 35 | [self.expireDateTextField setDelegate:self]; 36 | [self.usStateCodeTextField setDelegate:self]; 37 | } 38 | 39 | - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 40 | if ([textField isKindOfClass:[NGMaskedTextField class]]) { 41 | return [(NGMaskedTextField *)textField shouldChangeCharactersInRange:range replacementString:string]; 42 | } else { 43 | return YES; 44 | } 45 | } 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Example/Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NGMaskedTextField 2 | NGMaskedTextField makes it easy to apply masks on text fields. You can create phone number, date, time and lots of other masks by NGMaskedTextField. 3 | 4 | #Installation 5 | You can install NGMaskedTextField in your project by following two methods: 6 | 7 | 1) Download the source code and copy the NGMaskedTextField class files into your project. 8 | 9 | OR 10 | 11 | 2) Use cocoa pods. Add following line to Podfile. 12 | 13 | ``` 14 | pod 'NGMaskedTextField' 15 | ``` 16 | 17 | #Usage 18 | 19 | To use NGMaskedTextField you need to import NGMaskedTextField.h by following code: 20 | 21 | ``` 22 | import "NGMaskedTextField.h" 23 | ``` 24 | 25 | Now you can set masks and delegates of text fields. Sample usage is like following code: 26 | 27 | ``` 28 | //set text fields' masks 29 | [self.phoneNumberTextField setMaskString:@"(###) ###-####"]; 30 | [self.dateTextField setMaskString:@"##/##/####"]; 31 | [self.hourTextField setMaskString:@"##:##:##"]; 32 | [self.usStateCodeTextField setMaskString:@"??"]; 33 | 34 | //set delagete of text fileds as 'self' 35 | [self.phoneNumberTextField setDelegate:self]; 36 | [self.dateTextField setDelegate:self]; 37 | [self.hourTextField setDelegate:self]; 38 | [self.usStateCodeTextField setDelegate:self]; 39 | ``` 40 | 41 | And lastly wherever you want to use NGMaskedTextField you should implement below method in order to mask to be applied: 42 | ``` 43 | - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 44 | if ([textField isKindOfClass:[NGMaskedTextField class]]) { 45 | return [(NGMaskedTextField *)textField shouldChangeCharactersInRange:range replacementString:string]; 46 | } else { 47 | return YES; 48 | } 49 | } 50 | ``` 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Example/Example/NGMaskedTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // NGMaskedTextField.m 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import "NGMaskedTextField.h" 10 | 11 | NSString *kMaskedTextFieldDefaultCharacterMask = @"?"; 12 | NSString *kMaskedTextFieldDefaultNumberMask = @"#"; 13 | NSString *kMaskedTextFieldDefaultFill = @""; 14 | 15 | @interface NGMaskedTextField () 16 | 17 | @end 18 | 19 | @implementation NGMaskedTextField 20 | 21 | @synthesize inputString = _inputString; 22 | 23 | - (instancetype)initWithCoder:(NSCoder *)coder 24 | { 25 | self = [super initWithCoder:coder]; 26 | if (self) { 27 | [self setDefaultCharacterMask:kMaskedTextFieldDefaultCharacterMask]; 28 | [self setDefaultNumberMask:kMaskedTextFieldDefaultNumberMask]; 29 | [self setDefaultFill:kMaskedTextFieldDefaultFill]; 30 | 31 | [self addTarget:self action:@selector(textFieldValueDidChange) forControlEvents:UIControlEventEditingChanged]; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)initWithFrame:(CGRect)frame 37 | { 38 | self = [super initWithFrame:frame]; 39 | if (self) { 40 | [self setDefaultCharacterMask:kMaskedTextFieldDefaultCharacterMask]; 41 | [self setDefaultNumberMask:kMaskedTextFieldDefaultNumberMask]; 42 | [self setDefaultFill:kMaskedTextFieldDefaultFill]; 43 | 44 | [self addTarget:self action:@selector(textFieldValueDidChange) forControlEvents:UIControlEventEditingChanged]; 45 | } 46 | return self; 47 | } 48 | 49 | 50 | - (BOOL)shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 51 | if (self.maskString == nil) { 52 | return YES; 53 | } 54 | 55 | if (range.length > 0) { 56 | if (self.inputString.length >= range.length) { 57 | // removing characters with length: range.length 58 | self.inputString = [self.inputString substringWithRange:NSMakeRange(0, self.inputString.length - range.length)]; 59 | } else { 60 | // input string is not long enough to delete 61 | return NO; 62 | } 63 | } 64 | 65 | if (string.length > 1) { 66 | // inserting more than 1 character at once 67 | 68 | NSMutableArray *multipleCharString = [NSMutableArray array]; 69 | for (int i = 0; i 0) { 80 | // adding characters with length: string.length 81 | if (self.inputString.length + string.length <= [self desiredInputLength]) { 82 | NSInteger chartype = [self desiredInputCharacterTypeForOffset:0]; 83 | NSCharacterSet *desiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"abcçdefgğhıijklmnoöprsştuüvyzqwxABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZQWX0123456789"]; 84 | if (chartype == 1) { 85 | desiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"abcçdefgğhıijklmnoöprsştuüvyzqwxABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZQWX"]; 86 | } else if (chartype == 2) { 87 | desiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"]; 88 | } 89 | 90 | if ([desiredCharacterSet isSupersetOfSet:[NSCharacterSet characterSetWithCharactersInString:[string substringToIndex:1]]]) { 91 | self.inputString = [NSString stringWithFormat:@"%@%@", self.inputString, string]; 92 | } else { 93 | // character is not suitable for mask 94 | return NO; 95 | } 96 | } else { 97 | // input is too long to add 98 | return NO; 99 | } 100 | } 101 | return YES; 102 | } 103 | 104 | - (void)textFieldValueDidChange { 105 | if (self.maskString != nil) { 106 | [self setText:[self executeMaskOnInput]]; 107 | } 108 | } 109 | 110 | - (NSString *)inputString { 111 | if (_inputString == nil) { 112 | _inputString = @""; 113 | } 114 | return _inputString; 115 | } 116 | 117 | - (void)setInputString:(NSString *)inputString { 118 | _inputString = inputString; 119 | if (self.inputString.length == 0) { 120 | [self setText:@""]; 121 | } 122 | } 123 | 124 | - (void)setMaskString:(NSString *)maskString { 125 | _maskString = maskString; 126 | [self setText:[self executeMaskOnInput]]; 127 | if (self.inputString.length == 0) { 128 | [self setText:@""]; 129 | } 130 | } 131 | 132 | - (NSString *)executeMaskOnInput { 133 | NSMutableString *mutableString = [NSMutableString string]; 134 | NSInteger inputIndex = 0; 135 | for (int i = 0; i < self.maskString.length; i++) { 136 | if ([self.maskString characterAtIndex:i] == [self.defaultCharacterMask characterAtIndex:0] || [self.maskString characterAtIndex:i] == [self.defaultNumberMask characterAtIndex:0]) { 137 | if (inputIndex < self.inputString.length) { 138 | [mutableString appendString:[NSString stringWithFormat:@"%c", [self.inputString characterAtIndex:inputIndex]]]; 139 | inputIndex++; 140 | } else { 141 | [mutableString appendString:self.defaultFill]; 142 | } 143 | } else { 144 | [mutableString appendString:[NSString stringWithFormat:@"%c", [self.maskString characterAtIndex:i]]]; 145 | } 146 | } 147 | return mutableString; 148 | } 149 | 150 | - (NSInteger)desiredInputLength { 151 | int length = 0; 152 | for (int i = 0; i < self.maskString.length; i++) { 153 | if ([self.maskString characterAtIndex:i] == [self.defaultCharacterMask characterAtIndex:0] || 154 | [self.maskString characterAtIndex:i] == [self.defaultNumberMask characterAtIndex:0]) { 155 | length++; 156 | } 157 | } 158 | return length; 159 | } 160 | 161 | - (NSInteger)desiredInputCharacterTypeForOffset:(NSInteger)offset { 162 | NSMutableString *maskString = [NSMutableString stringWithString:self.maskString]; 163 | 164 | for (int i = 0; i < self.inputString.length; i++) { 165 | for (int j = 0; j < maskString.length; j++) { 166 | if ([maskString characterAtIndex:j] == [self.defaultCharacterMask characterAtIndex:0] || 167 | [maskString characterAtIndex:j] == [self.defaultNumberMask characterAtIndex:0]) { 168 | [maskString replaceCharactersInRange:NSMakeRange(j, 1) withString:self.defaultFill]; 169 | break; 170 | } 171 | } 172 | } 173 | 174 | for (int i = 0; i < maskString.length; i++) { 175 | if ([maskString characterAtIndex:i] == [self.defaultCharacterMask characterAtIndex:0]) { 176 | return 1; 177 | } else if ([maskString characterAtIndex:i] == [self.defaultNumberMask characterAtIndex:0]) { 178 | return 2; 179 | } 180 | } 181 | 182 | return -1; 183 | } 184 | 185 | - (CGRect)caretRectForPosition:(UITextPosition *)position { 186 | if (self.maskString == nil) { 187 | return [super caretRectForPosition:position]; 188 | } else { 189 | return [super caretRectForPosition:position]; 190 | 191 | } 192 | } 193 | 194 | @end 195 | -------------------------------------------------------------------------------- /Classes/NGMaskedTextField.m: -------------------------------------------------------------------------------- 1 | // 2 | // NGMaskedTextField.m 3 | // Example 4 | // 5 | // Created by Berk on 05/02/16. 6 | // Copyright © 2016 Berk Dilek. All rights reserved. 7 | // 8 | 9 | #import "NGMaskedTextField.h" 10 | 11 | NSString *kMaskedTextFieldDefaultCharacterMask = @"?"; 12 | NSString *kMaskedTextFieldDefaultNumberMask = @"#"; 13 | NSString *kMaskedTextFieldDefaultFill = @""; 14 | 15 | @interface NGMaskedTextField () 16 | 17 | @end 18 | 19 | @implementation NGMaskedTextField 20 | 21 | @synthesize inputString = _inputString; 22 | 23 | - (instancetype)initWithCoder:(NSCoder *)coder 24 | { 25 | self = [super initWithCoder:coder]; 26 | if (self) { 27 | [self setDefaultCharacterMask:kMaskedTextFieldDefaultCharacterMask]; 28 | [self setDefaultNumberMask:kMaskedTextFieldDefaultNumberMask]; 29 | [self setDefaultFill:kMaskedTextFieldDefaultFill]; 30 | 31 | [self addTarget:self action:@selector(textFieldValueDidChange) forControlEvents:UIControlEventEditingChanged]; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)initWithFrame:(CGRect)frame 37 | { 38 | self = [super initWithFrame:frame]; 39 | if (self) { 40 | [self setDefaultCharacterMask:kMaskedTextFieldDefaultCharacterMask]; 41 | [self setDefaultNumberMask:kMaskedTextFieldDefaultNumberMask]; 42 | [self setDefaultFill:kMaskedTextFieldDefaultFill]; 43 | 44 | [self addTarget:self action:@selector(textFieldValueDidChange) forControlEvents:UIControlEventEditingChanged]; 45 | } 46 | return self; 47 | } 48 | 49 | 50 | - (BOOL)shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 51 | if (self.maskString == nil) { 52 | return YES; 53 | } 54 | 55 | if (range.length > 0) { 56 | if (self.inputString.length >= range.length) { 57 | // removing characters with length: range.length 58 | self.inputString = [self.inputString substringWithRange:NSMakeRange(0, self.inputString.length - range.length)]; 59 | } else { 60 | // input string is not long enough to delete 61 | return NO; 62 | } 63 | } 64 | 65 | if (string.length > 1) { 66 | // inserting more than 1 character at once 67 | 68 | NSMutableArray *multipleCharString = [NSMutableArray array]; 69 | for (int i = 0; i 0) { 81 | // adding characters with length: string.length 82 | if (self.inputString.length + string.length <= [self desiredInputLength]) { 83 | NSInteger chartype = [self desiredInputCharacterTypeForOffset:0]; 84 | NSCharacterSet *desiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"abcçdefgğhıijklmnoöprsştuüvyzqwxABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZQWX0123456789"]; 85 | if (chartype == 1) { 86 | desiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"abcçdefgğhıijklmnoöprsştuüvyzqwxABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZQWX"]; 87 | } else if (chartype == 2) { 88 | desiredCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"]; 89 | } 90 | 91 | if ([desiredCharacterSet isSupersetOfSet:[NSCharacterSet characterSetWithCharactersInString:[string substringToIndex:1]]]) { 92 | self.inputString = [NSString stringWithFormat:@"%@%@", self.inputString, string]; 93 | } else { 94 | // character is not suitable for mask 95 | return NO; 96 | } 97 | } else { 98 | // input is too long to add 99 | return NO; 100 | } 101 | } 102 | return YES; 103 | } 104 | 105 | - (void)textFieldValueDidChange { 106 | if (self.maskString != nil) { 107 | [self setText:[self executeMaskOnInput]]; 108 | } 109 | } 110 | 111 | - (NSString *)inputString { 112 | if (_inputString == nil) { 113 | _inputString = @""; 114 | } 115 | return _inputString; 116 | } 117 | 118 | - (void)setInputString:(NSString *)inputString { 119 | _inputString = inputString; 120 | if (self.inputString.length == 0) { 121 | [self setText:@""]; 122 | } 123 | } 124 | 125 | - (void)setMaskString:(NSString *)maskString { 126 | _maskString = maskString; 127 | [self setText:[self executeMaskOnInput]]; 128 | if (self.inputString.length == 0) { 129 | [self setText:@""]; 130 | } 131 | } 132 | 133 | - (NSString *)executeMaskOnInput { 134 | NSMutableString *mutableString = [NSMutableString string]; 135 | NSInteger inputIndex = 0; 136 | for (int i = 0; i < self.maskString.length; i++) { 137 | if ([self.maskString characterAtIndex:i] == [self.defaultCharacterMask characterAtIndex:0] || [self.maskString characterAtIndex:i] == [self.defaultNumberMask characterAtIndex:0]) { 138 | if (inputIndex < self.inputString.length) { 139 | [mutableString appendString:[NSString stringWithFormat:@"%c", [self.inputString characterAtIndex:inputIndex]]]; 140 | inputIndex++; 141 | } else { 142 | [mutableString appendString:self.defaultFill]; 143 | } 144 | } else { 145 | [mutableString appendString:[NSString stringWithFormat:@"%c", [self.maskString characterAtIndex:i]]]; 146 | } 147 | } 148 | return mutableString; 149 | } 150 | 151 | - (NSInteger)desiredInputLength { 152 | int length = 0; 153 | for (int i = 0; i < self.maskString.length; i++) { 154 | if ([self.maskString characterAtIndex:i] == [self.defaultCharacterMask characterAtIndex:0] || 155 | [self.maskString characterAtIndex:i] == [self.defaultNumberMask characterAtIndex:0]) { 156 | length++; 157 | } 158 | } 159 | return length; 160 | } 161 | 162 | - (NSInteger)desiredInputCharacterTypeForOffset:(NSInteger)offset { 163 | NSMutableString *maskString = [NSMutableString stringWithString:self.maskString]; 164 | 165 | for (int i = 0; i < self.inputString.length; i++) { 166 | for (int j = 0; j < maskString.length; j++) { 167 | if ([maskString characterAtIndex:j] == [self.defaultCharacterMask characterAtIndex:0] || 168 | [maskString characterAtIndex:j] == [self.defaultNumberMask characterAtIndex:0]) { 169 | [maskString replaceCharactersInRange:NSMakeRange(j, 1) withString:self.defaultFill]; 170 | break; 171 | } 172 | } 173 | } 174 | 175 | for (int i = 0; i < maskString.length; i++) { 176 | if ([maskString characterAtIndex:i] == [self.defaultCharacterMask characterAtIndex:0]) { 177 | return 1; 178 | } else if ([maskString characterAtIndex:i] == [self.defaultNumberMask characterAtIndex:0]) { 179 | return 2; 180 | } 181 | } 182 | 183 | return -1; 184 | } 185 | 186 | - (CGRect)caretRectForPosition:(UITextPosition *)position { 187 | if (self.maskString == nil) { 188 | return [super caretRectForPosition:position]; 189 | } else { 190 | // return CGRectZero; 191 | return [super caretRectForPosition:position]; 192 | 193 | } 194 | } 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /Example/Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 65 | 74 | 83 | 92 | 101 | 110 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 18F7CB0F1C648F650083AFCE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB0E1C648F650083AFCE /* main.m */; }; 11 | 18F7CB121C648F650083AFCE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB111C648F650083AFCE /* AppDelegate.m */; }; 12 | 18F7CB151C648F650083AFCE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB141C648F650083AFCE /* ViewController.m */; }; 13 | 18F7CB181C648F650083AFCE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18F7CB161C648F650083AFCE /* Main.storyboard */; }; 14 | 18F7CB1A1C648F650083AFCE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18F7CB191C648F650083AFCE /* Assets.xcassets */; }; 15 | 18F7CB1D1C648F650083AFCE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18F7CB1B1C648F650083AFCE /* LaunchScreen.storyboard */; }; 16 | 18F7CB281C648F650083AFCE /* ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB271C648F650083AFCE /* ExampleTests.m */; }; 17 | 18F7CB331C648F650083AFCE /* ExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB321C648F650083AFCE /* ExampleUITests.m */; }; 18 | 18F7CB421C648F990083AFCE /* NGMaskedTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB411C648F990083AFCE /* NGMaskedTextField.m */; }; 19 | 18F7CB431C648F990083AFCE /* NGMaskedTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB411C648F990083AFCE /* NGMaskedTextField.m */; }; 20 | 18F7CB441C648F990083AFCE /* NGMaskedTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 18F7CB411C648F990083AFCE /* NGMaskedTextField.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 18F7CB241C648F650083AFCE /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 18F7CB021C648F650083AFCE /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 18F7CB091C648F650083AFCE; 29 | remoteInfo = Example; 30 | }; 31 | 18F7CB2F1C648F650083AFCE /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 18F7CB021C648F650083AFCE /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = 18F7CB091C648F650083AFCE; 36 | remoteInfo = Example; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 18F7CB0A1C648F650083AFCE /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 18F7CB0E1C648F650083AFCE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 18F7CB101C648F650083AFCE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 18F7CB111C648F650083AFCE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 18F7CB131C648F650083AFCE /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 46 | 18F7CB141C648F650083AFCE /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 47 | 18F7CB171C648F650083AFCE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 48 | 18F7CB191C648F650083AFCE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 49 | 18F7CB1C1C648F650083AFCE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 50 | 18F7CB1E1C648F650083AFCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 51 | 18F7CB231C648F650083AFCE /* ExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 18F7CB271C648F650083AFCE /* ExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExampleTests.m; sourceTree = ""; }; 53 | 18F7CB291C648F650083AFCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 18F7CB2E1C648F650083AFCE /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 18F7CB321C648F650083AFCE /* ExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExampleUITests.m; sourceTree = ""; }; 56 | 18F7CB341C648F650083AFCE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 18F7CB401C648F990083AFCE /* NGMaskedTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NGMaskedTextField.h; sourceTree = ""; }; 58 | 18F7CB411C648F990083AFCE /* NGMaskedTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NGMaskedTextField.m; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 18F7CB071C648F650083AFCE /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 18F7CB201C648F650083AFCE /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 18F7CB2B1C648F650083AFCE /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 18F7CB011C648F650083AFCE = { 87 | isa = PBXGroup; 88 | children = ( 89 | 18F7CB0C1C648F650083AFCE /* Example */, 90 | 18F7CB261C648F650083AFCE /* ExampleTests */, 91 | 18F7CB311C648F650083AFCE /* ExampleUITests */, 92 | 18F7CB0B1C648F650083AFCE /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 18F7CB0B1C648F650083AFCE /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 18F7CB0A1C648F650083AFCE /* Example.app */, 100 | 18F7CB231C648F650083AFCE /* ExampleTests.xctest */, 101 | 18F7CB2E1C648F650083AFCE /* ExampleUITests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 18F7CB0C1C648F650083AFCE /* Example */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 18F7CB101C648F650083AFCE /* AppDelegate.h */, 110 | 18F7CB111C648F650083AFCE /* AppDelegate.m */, 111 | 18F7CB131C648F650083AFCE /* ViewController.h */, 112 | 18F7CB141C648F650083AFCE /* ViewController.m */, 113 | 18F7CB401C648F990083AFCE /* NGMaskedTextField.h */, 114 | 18F7CB411C648F990083AFCE /* NGMaskedTextField.m */, 115 | 18F7CB161C648F650083AFCE /* Main.storyboard */, 116 | 18F7CB191C648F650083AFCE /* Assets.xcassets */, 117 | 18F7CB1B1C648F650083AFCE /* LaunchScreen.storyboard */, 118 | 18F7CB1E1C648F650083AFCE /* Info.plist */, 119 | 18F7CB0D1C648F650083AFCE /* Supporting Files */, 120 | ); 121 | path = Example; 122 | sourceTree = ""; 123 | }; 124 | 18F7CB0D1C648F650083AFCE /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 18F7CB0E1C648F650083AFCE /* main.m */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | 18F7CB261C648F650083AFCE /* ExampleTests */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 18F7CB271C648F650083AFCE /* ExampleTests.m */, 136 | 18F7CB291C648F650083AFCE /* Info.plist */, 137 | ); 138 | path = ExampleTests; 139 | sourceTree = ""; 140 | }; 141 | 18F7CB311C648F650083AFCE /* ExampleUITests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 18F7CB321C648F650083AFCE /* ExampleUITests.m */, 145 | 18F7CB341C648F650083AFCE /* Info.plist */, 146 | ); 147 | path = ExampleUITests; 148 | sourceTree = ""; 149 | }; 150 | /* End PBXGroup section */ 151 | 152 | /* Begin PBXNativeTarget section */ 153 | 18F7CB091C648F650083AFCE /* Example */ = { 154 | isa = PBXNativeTarget; 155 | buildConfigurationList = 18F7CB371C648F650083AFCE /* Build configuration list for PBXNativeTarget "Example" */; 156 | buildPhases = ( 157 | 18F7CB061C648F650083AFCE /* Sources */, 158 | 18F7CB071C648F650083AFCE /* Frameworks */, 159 | 18F7CB081C648F650083AFCE /* Resources */, 160 | ); 161 | buildRules = ( 162 | ); 163 | dependencies = ( 164 | ); 165 | name = Example; 166 | productName = Example; 167 | productReference = 18F7CB0A1C648F650083AFCE /* Example.app */; 168 | productType = "com.apple.product-type.application"; 169 | }; 170 | 18F7CB221C648F650083AFCE /* ExampleTests */ = { 171 | isa = PBXNativeTarget; 172 | buildConfigurationList = 18F7CB3A1C648F650083AFCE /* Build configuration list for PBXNativeTarget "ExampleTests" */; 173 | buildPhases = ( 174 | 18F7CB1F1C648F650083AFCE /* Sources */, 175 | 18F7CB201C648F650083AFCE /* Frameworks */, 176 | 18F7CB211C648F650083AFCE /* Resources */, 177 | ); 178 | buildRules = ( 179 | ); 180 | dependencies = ( 181 | 18F7CB251C648F650083AFCE /* PBXTargetDependency */, 182 | ); 183 | name = ExampleTests; 184 | productName = ExampleTests; 185 | productReference = 18F7CB231C648F650083AFCE /* ExampleTests.xctest */; 186 | productType = "com.apple.product-type.bundle.unit-test"; 187 | }; 188 | 18F7CB2D1C648F650083AFCE /* ExampleUITests */ = { 189 | isa = PBXNativeTarget; 190 | buildConfigurationList = 18F7CB3D1C648F650083AFCE /* Build configuration list for PBXNativeTarget "ExampleUITests" */; 191 | buildPhases = ( 192 | 18F7CB2A1C648F650083AFCE /* Sources */, 193 | 18F7CB2B1C648F650083AFCE /* Frameworks */, 194 | 18F7CB2C1C648F650083AFCE /* Resources */, 195 | ); 196 | buildRules = ( 197 | ); 198 | dependencies = ( 199 | 18F7CB301C648F650083AFCE /* PBXTargetDependency */, 200 | ); 201 | name = ExampleUITests; 202 | productName = ExampleUITests; 203 | productReference = 18F7CB2E1C648F650083AFCE /* ExampleUITests.xctest */; 204 | productType = "com.apple.product-type.bundle.ui-testing"; 205 | }; 206 | /* End PBXNativeTarget section */ 207 | 208 | /* Begin PBXProject section */ 209 | 18F7CB021C648F650083AFCE /* Project object */ = { 210 | isa = PBXProject; 211 | attributes = { 212 | LastUpgradeCheck = 0710; 213 | ORGANIZATIONNAME = "Berk Dilek"; 214 | TargetAttributes = { 215 | 18F7CB091C648F650083AFCE = { 216 | CreatedOnToolsVersion = 7.1.1; 217 | }; 218 | 18F7CB221C648F650083AFCE = { 219 | CreatedOnToolsVersion = 7.1.1; 220 | TestTargetID = 18F7CB091C648F650083AFCE; 221 | }; 222 | 18F7CB2D1C648F650083AFCE = { 223 | CreatedOnToolsVersion = 7.1.1; 224 | TestTargetID = 18F7CB091C648F650083AFCE; 225 | }; 226 | }; 227 | }; 228 | buildConfigurationList = 18F7CB051C648F650083AFCE /* Build configuration list for PBXProject "Example" */; 229 | compatibilityVersion = "Xcode 3.2"; 230 | developmentRegion = English; 231 | hasScannedForEncodings = 0; 232 | knownRegions = ( 233 | en, 234 | Base, 235 | ); 236 | mainGroup = 18F7CB011C648F650083AFCE; 237 | productRefGroup = 18F7CB0B1C648F650083AFCE /* Products */; 238 | projectDirPath = ""; 239 | projectRoot = ""; 240 | targets = ( 241 | 18F7CB091C648F650083AFCE /* Example */, 242 | 18F7CB221C648F650083AFCE /* ExampleTests */, 243 | 18F7CB2D1C648F650083AFCE /* ExampleUITests */, 244 | ); 245 | }; 246 | /* End PBXProject section */ 247 | 248 | /* Begin PBXResourcesBuildPhase section */ 249 | 18F7CB081C648F650083AFCE /* Resources */ = { 250 | isa = PBXResourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 18F7CB1D1C648F650083AFCE /* LaunchScreen.storyboard in Resources */, 254 | 18F7CB1A1C648F650083AFCE /* Assets.xcassets in Resources */, 255 | 18F7CB181C648F650083AFCE /* Main.storyboard in Resources */, 256 | ); 257 | runOnlyForDeploymentPostprocessing = 0; 258 | }; 259 | 18F7CB211C648F650083AFCE /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | 18F7CB2C1C648F650083AFCE /* Resources */ = { 267 | isa = PBXResourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | runOnlyForDeploymentPostprocessing = 0; 272 | }; 273 | /* End PBXResourcesBuildPhase section */ 274 | 275 | /* Begin PBXSourcesBuildPhase section */ 276 | 18F7CB061C648F650083AFCE /* Sources */ = { 277 | isa = PBXSourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | 18F7CB151C648F650083AFCE /* ViewController.m in Sources */, 281 | 18F7CB421C648F990083AFCE /* NGMaskedTextField.m in Sources */, 282 | 18F7CB121C648F650083AFCE /* AppDelegate.m in Sources */, 283 | 18F7CB0F1C648F650083AFCE /* main.m in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 18F7CB1F1C648F650083AFCE /* Sources */ = { 288 | isa = PBXSourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 18F7CB281C648F650083AFCE /* ExampleTests.m in Sources */, 292 | 18F7CB431C648F990083AFCE /* NGMaskedTextField.m in Sources */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | 18F7CB2A1C648F650083AFCE /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | 18F7CB331C648F650083AFCE /* ExampleUITests.m in Sources */, 301 | 18F7CB441C648F990083AFCE /* NGMaskedTextField.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | /* End PBXSourcesBuildPhase section */ 306 | 307 | /* Begin PBXTargetDependency section */ 308 | 18F7CB251C648F650083AFCE /* PBXTargetDependency */ = { 309 | isa = PBXTargetDependency; 310 | target = 18F7CB091C648F650083AFCE /* Example */; 311 | targetProxy = 18F7CB241C648F650083AFCE /* PBXContainerItemProxy */; 312 | }; 313 | 18F7CB301C648F650083AFCE /* PBXTargetDependency */ = { 314 | isa = PBXTargetDependency; 315 | target = 18F7CB091C648F650083AFCE /* Example */; 316 | targetProxy = 18F7CB2F1C648F650083AFCE /* PBXContainerItemProxy */; 317 | }; 318 | /* End PBXTargetDependency section */ 319 | 320 | /* Begin PBXVariantGroup section */ 321 | 18F7CB161C648F650083AFCE /* Main.storyboard */ = { 322 | isa = PBXVariantGroup; 323 | children = ( 324 | 18F7CB171C648F650083AFCE /* Base */, 325 | ); 326 | name = Main.storyboard; 327 | sourceTree = ""; 328 | }; 329 | 18F7CB1B1C648F650083AFCE /* LaunchScreen.storyboard */ = { 330 | isa = PBXVariantGroup; 331 | children = ( 332 | 18F7CB1C1C648F650083AFCE /* Base */, 333 | ); 334 | name = LaunchScreen.storyboard; 335 | sourceTree = ""; 336 | }; 337 | /* End PBXVariantGroup section */ 338 | 339 | /* Begin XCBuildConfiguration section */ 340 | 18F7CB351C648F650083AFCE /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | ALWAYS_SEARCH_USER_PATHS = NO; 344 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 345 | CLANG_CXX_LIBRARY = "libc++"; 346 | CLANG_ENABLE_MODULES = YES; 347 | CLANG_ENABLE_OBJC_ARC = YES; 348 | CLANG_WARN_BOOL_CONVERSION = YES; 349 | CLANG_WARN_CONSTANT_CONVERSION = YES; 350 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 351 | CLANG_WARN_EMPTY_BODY = YES; 352 | CLANG_WARN_ENUM_CONVERSION = YES; 353 | CLANG_WARN_INT_CONVERSION = YES; 354 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 355 | CLANG_WARN_UNREACHABLE_CODE = YES; 356 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 357 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 358 | COPY_PHASE_STRIP = NO; 359 | DEBUG_INFORMATION_FORMAT = dwarf; 360 | ENABLE_STRICT_OBJC_MSGSEND = YES; 361 | ENABLE_TESTABILITY = YES; 362 | GCC_C_LANGUAGE_STANDARD = gnu99; 363 | GCC_DYNAMIC_NO_PIC = NO; 364 | GCC_NO_COMMON_BLOCKS = YES; 365 | GCC_OPTIMIZATION_LEVEL = 0; 366 | GCC_PREPROCESSOR_DEFINITIONS = ( 367 | "DEBUG=1", 368 | "$(inherited)", 369 | ); 370 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 372 | GCC_WARN_UNDECLARED_SELECTOR = YES; 373 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 374 | GCC_WARN_UNUSED_FUNCTION = YES; 375 | GCC_WARN_UNUSED_VARIABLE = YES; 376 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 377 | MTL_ENABLE_DEBUG_INFO = YES; 378 | ONLY_ACTIVE_ARCH = YES; 379 | SDKROOT = iphoneos; 380 | }; 381 | name = Debug; 382 | }; 383 | 18F7CB361C648F650083AFCE /* Release */ = { 384 | isa = XCBuildConfiguration; 385 | buildSettings = { 386 | ALWAYS_SEARCH_USER_PATHS = NO; 387 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 388 | CLANG_CXX_LIBRARY = "libc++"; 389 | CLANG_ENABLE_MODULES = YES; 390 | CLANG_ENABLE_OBJC_ARC = YES; 391 | CLANG_WARN_BOOL_CONVERSION = YES; 392 | CLANG_WARN_CONSTANT_CONVERSION = YES; 393 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 394 | CLANG_WARN_EMPTY_BODY = YES; 395 | CLANG_WARN_ENUM_CONVERSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_UNREACHABLE_CODE = YES; 399 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 400 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 401 | COPY_PHASE_STRIP = NO; 402 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 403 | ENABLE_NS_ASSERTIONS = NO; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | GCC_C_LANGUAGE_STANDARD = gnu99; 406 | GCC_NO_COMMON_BLOCKS = YES; 407 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 408 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 409 | GCC_WARN_UNDECLARED_SELECTOR = YES; 410 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 411 | GCC_WARN_UNUSED_FUNCTION = YES; 412 | GCC_WARN_UNUSED_VARIABLE = YES; 413 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 414 | MTL_ENABLE_DEBUG_INFO = NO; 415 | SDKROOT = iphoneos; 416 | VALIDATE_PRODUCT = YES; 417 | }; 418 | name = Release; 419 | }; 420 | 18F7CB381C648F650083AFCE /* Debug */ = { 421 | isa = XCBuildConfiguration; 422 | buildSettings = { 423 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 424 | INFOPLIST_FILE = Example/Info.plist; 425 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 426 | PRODUCT_BUNDLE_IDENTIFIER = com.berkdilek.Example; 427 | PRODUCT_NAME = "$(TARGET_NAME)"; 428 | }; 429 | name = Debug; 430 | }; 431 | 18F7CB391C648F650083AFCE /* Release */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 435 | INFOPLIST_FILE = Example/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 437 | PRODUCT_BUNDLE_IDENTIFIER = com.berkdilek.Example; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | }; 440 | name = Release; 441 | }; 442 | 18F7CB3B1C648F650083AFCE /* Debug */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | BUNDLE_LOADER = "$(TEST_HOST)"; 446 | INFOPLIST_FILE = ExampleTests/Info.plist; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 448 | PRODUCT_BUNDLE_IDENTIFIER = com.berkdilek.ExampleTests; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; 451 | }; 452 | name = Debug; 453 | }; 454 | 18F7CB3C1C648F650083AFCE /* Release */ = { 455 | isa = XCBuildConfiguration; 456 | buildSettings = { 457 | BUNDLE_LOADER = "$(TEST_HOST)"; 458 | INFOPLIST_FILE = ExampleTests/Info.plist; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 460 | PRODUCT_BUNDLE_IDENTIFIER = com.berkdilek.ExampleTests; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; 463 | }; 464 | name = Release; 465 | }; 466 | 18F7CB3E1C648F650083AFCE /* Debug */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | INFOPLIST_FILE = ExampleUITests/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = com.berkdilek.ExampleUITests; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TEST_TARGET_NAME = Example; 474 | USES_XCTRUNNER = YES; 475 | }; 476 | name = Debug; 477 | }; 478 | 18F7CB3F1C648F650083AFCE /* Release */ = { 479 | isa = XCBuildConfiguration; 480 | buildSettings = { 481 | INFOPLIST_FILE = ExampleUITests/Info.plist; 482 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 483 | PRODUCT_BUNDLE_IDENTIFIER = com.berkdilek.ExampleUITests; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | TEST_TARGET_NAME = Example; 486 | USES_XCTRUNNER = YES; 487 | }; 488 | name = Release; 489 | }; 490 | /* End XCBuildConfiguration section */ 491 | 492 | /* Begin XCConfigurationList section */ 493 | 18F7CB051C648F650083AFCE /* Build configuration list for PBXProject "Example" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | 18F7CB351C648F650083AFCE /* Debug */, 497 | 18F7CB361C648F650083AFCE /* Release */, 498 | ); 499 | defaultConfigurationIsVisible = 0; 500 | defaultConfigurationName = Release; 501 | }; 502 | 18F7CB371C648F650083AFCE /* Build configuration list for PBXNativeTarget "Example" */ = { 503 | isa = XCConfigurationList; 504 | buildConfigurations = ( 505 | 18F7CB381C648F650083AFCE /* Debug */, 506 | 18F7CB391C648F650083AFCE /* Release */, 507 | ); 508 | defaultConfigurationIsVisible = 0; 509 | }; 510 | 18F7CB3A1C648F650083AFCE /* Build configuration list for PBXNativeTarget "ExampleTests" */ = { 511 | isa = XCConfigurationList; 512 | buildConfigurations = ( 513 | 18F7CB3B1C648F650083AFCE /* Debug */, 514 | 18F7CB3C1C648F650083AFCE /* Release */, 515 | ); 516 | defaultConfigurationIsVisible = 0; 517 | }; 518 | 18F7CB3D1C648F650083AFCE /* Build configuration list for PBXNativeTarget "ExampleUITests" */ = { 519 | isa = XCConfigurationList; 520 | buildConfigurations = ( 521 | 18F7CB3E1C648F650083AFCE /* Debug */, 522 | 18F7CB3F1C648F650083AFCE /* Release */, 523 | ); 524 | defaultConfigurationIsVisible = 0; 525 | }; 526 | /* End XCConfigurationList section */ 527 | }; 528 | rootObject = 18F7CB021C648F650083AFCE /* Project object */; 529 | } 530 | --------------------------------------------------------------------------------