no message

This commit is contained in:
giuseppenuc committed 2015-09-01 10:12:44 +02:00
1 parent 7b2d0e8670
commit 540a8620e1
57 files changed
+1828 -771

No files matched your search

+19
View File
@@ -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
+38
View File
@@ -0,0 +1,38 @@
# NSString-Helper
[![CI Status](http://img.shields.io/travis/Giuseppe Nucifora/NSString-Helper.svg?style=flat)](https://travis-ci.org/Giuseppe Nucifora/NSString-Helper)
[![Version](https://img.shields.io/cocoapods/v/NSString-Helper.svg?style=flat)](http://cocoapods.org/pods/NSString-Helper)
[![License](https://img.shields.io/cocoapods/l/NSString-Helper.svg?style=flat)](http://cocoapods.org/pods/NSString-Helper)
[![Platform](https://img.shields.io/cocoapods/p/NSString-Helper.svg?style=flat)](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.