no message
This commit is contained in:
1 parent
7b2d0e8670
commit
540a8620e1
57 files changed
+1828
-771
No files matched your search
Generated
+19
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2015 Giuseppe Nucifora <me@giuseppenucifora.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// NSString+Helper.h
|
||||
//
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 02/07/15.
|
||||
// Copyright (c) 2015 Giuseppe Nucifora All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (Helper)
|
||||
|
||||
- (BOOL) isValidEmail;
|
||||
|
||||
- (BOOL) isNumeric;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// NSString+Helper.m
|
||||
//
|
||||
//
|
||||
// Created by Giuseppe Nucifora on 02/07/15.
|
||||
// Copyright (c) 2015 Giuseppe Nucifora All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSString+Helper.h"
|
||||
|
||||
@implementation NSString (Helper)
|
||||
|
||||
- (BOOL) isValidEmail
|
||||
{
|
||||
BOOL stricterFilter = YES;
|
||||
NSString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
|
||||
NSString *laxString = @".+@.+\\.[A-Za-z]{2}[A-Za-z]*";
|
||||
NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
|
||||
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
|
||||
return [emailTest evaluateWithObject:self];
|
||||
}
|
||||
|
||||
- (BOOL)isNumeric {
|
||||
BOOL isValid = NO;
|
||||
NSCharacterSet *alphaNumbersSet = [NSCharacterSet decimalDigitCharacterSet];
|
||||
NSCharacterSet *stringSet = [NSCharacterSet characterSetWithCharactersInString:self];
|
||||
isValid = [alphaNumbersSet isSupersetOfSet:stringSet];
|
||||
return isValid;
|
||||
}
|
||||
|
||||
@end
|
||||
Generated
+38
@@ -0,0 +1,38 @@
|
||||
# NSString-Helper
|
||||
|
||||
[](https://travis-ci.org/Giuseppe Nucifora/NSString-Helper)
|
||||
[](http://cocoapods.org/pods/NSString-Helper)
|
||||
[](http://cocoapods.org/pods/NSString-Helper)
|
||||
[](http://cocoapods.org/pods/NSString-Helper)
|
||||
|
||||
## Usage
|
||||
|
||||
To run the example project, clone the repo, and run `pod install` from the Example directory first.
|
||||
|
||||
## Requirements
|
||||
|
||||
## Installation
|
||||
|
||||
NSString-Helper is available through [CocoaPods](http://cocoapods.org). To install
|
||||
it, simply add the following line to your Podfile:
|
||||
|
||||
```ruby
|
||||
pod 'NSString-Helper' , :git => 'https://github.com/giuseppenucifora/NSString-Helper.git'
|
||||
```
|
||||
##Usage
|
||||
|
||||
```ruby
|
||||
NSString *str = @"testCode";
|
||||
|
||||
NSLog(@"%@",[NSNumber numberWithBool:[str isNumeric]]);
|
||||
|
||||
NSLog(@"%@",[NSNumber numberWithBool:[str isValidEmail]]);
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
Giuseppe Nucifora, me@giuseppenucifora.com
|
||||
|
||||
## License
|
||||
|
||||
NSString-Helper is available under the MIT license. See the LICENSE file for more info.
|
||||
Reference in new issue
Block a user