Skip to content

leleliu008/OC-Utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OC-Utils

Objective-C Common Use Utils

Usage

1、Add the following code to Podfile in your project:

pod 'OC-Utils', '~> 1.0.0'

2、Execute the following command to install this lib:

pod install

Base16

1、import OCBase16.h header:

#import "OCBase16.h"

2、Base16 Encode to UpperCase:

NSString *str = @"中国";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSString *base16EncodedStr = [OCBase16 encodeWithNSData:data];

3、Base16 Encode to LowerCase:

NSString *str = @"中国";
NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
NSString *base16EncodedStr2 = [OCBase16 encodeWithNSData:data toUpperCase:NO];

4、Base16 Decode Usage:

NSString *str = @"4142434445";
NSData *data = [OCBase16 decodeWithNSString:str];

URL

1、import OCURL.h header:

#import "OCURL.h"

2、URL Encode to UpperCase:

NSString *str = @"中国";
NSString *urlEncodedStr = [OCURL encodeWithNSString:str];

3、URL Encode to LowerCase:

NSString *str = @"中国";
NSString *urlEncodedStr = [OCURL encodeWithNSString:str toUpperCase:NO];

4、URL Decode Usage:

NSString *urlEncodedStr = @"%e4%b8%ad%e5%9b%bd";
NSData *urlDecodedData = [OCURL decode:urlEncodedStr];

License

OC-Utils is available under the MIT license. See the LICENSE file for more info.