- Fix Vari

This commit is contained in:
giuseppenuc committed 2016-01-26 00:29:37 +01:00
1 parent f569c8545c
commit 7e5a6149a8
28 files changed
+1162 -862

No files matched your search

@@ -14,6 +14,8 @@
- (BOOL) isNumeric;
- (BOOL) isValidPhoneNumber;
- (BOOL) isValidUrl;
- (BOOL) isValidTaxCode;
@@ -28,6 +28,22 @@
return isValid;
}
- (BOOL) isValidPhoneNumber {
NSError *error = NULL;
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypePhoneNumber error:&error];
NSArray *matches = [detector matchesInString:self options:0 range:NSMakeRange(0, [self length])];
if (matches != nil) {
for (NSTextCheckingResult *match in matches) {
if ([match resultType] == NSTextCheckingTypePhoneNumber) {
return YES;
}
}
}
return NO;
}
- (BOOL) isValidUrl {
NSString *urlRegEx =
@"(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+";
+5 -4
View File
@@ -17,19 +17,20 @@ NSString-Helper is available through [CocoaPods](http://cocoapods.org). To insta
it, simply add the following line to your Podfile:
```ruby
pod 'NSString-Helper' , :git => 'https://github.com/giuseppenucifora/NSString-Helper.git'
OR
pod 'NSString-Helper'
```
##Usage
```ruby
#import <NSString-Helper/NSString+Helper.h>
NSString *str = @"testCode";
NSLog(@"%@",[NSNumber numberWithBool:[str isNumeric]]);
NSLog(@"%@",[NSNumber numberWithBool:[str isValidPhoneNumber]]);
NSLog(@"%@",[NSNumber numberWithBool:[str isValidEmail]]);
NSLog(@"%@",[NSNumber numberWithBool:[str isValidUrl]]);