Skip to content

Instantly share code, notes, and snippets.

@supermarin
Created July 20, 2012 07:33
Show Gist options
  • Select an option

  • Save supermarin/3149303 to your computer and use it in GitHub Desktop.

Select an option

Save supermarin/3149303 to your computer and use it in GitHub Desktop.
New: iVars / static vars in OBJC categories
//
// NSString+DomainInput.m
// Domainchy
//
// Created by Marin Usalj on 7/13/12.
// Copyright (c) 2012 mneorr.com | @mneorr | [email protected]. All rights reserved.
//
#import "NSString+DomainInput.h"
@implementation NSString (DomainInput)
static NSString *allowedCharacters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ0123456789-.";
- (BOOL)isAllowedCharacter {
return [allowedCharacters containsString:self];
}
#pragma mark - Private
- (BOOL)containsString:(NSString *) string {
NSRange range = [self rangeOfString:string options:NSCaseInsensitiveSearch];
return range.location != NSNotFound;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment