Skip to content

Commit

Permalink
【ADD】'NSString+LYUnits'添加获取文件大小功能
Browse files Browse the repository at this point in the history
【ADD】'UIDevice+LYHardware'添加获取运营商功能
  • Loading branch information
吴浪 committed Dec 13, 2018
1 parent 5fe4150 commit 2ab2375
Show file tree
Hide file tree
Showing 13 changed files with 597 additions and 409 deletions.
16 changes: 8 additions & 8 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- LYToolsKit (0.2.0):
- LYToolsKit/Foundation (= 0.2.0)
- LYToolsKit/UI (= 0.2.0)
- LYToolsKit/Utility (= 0.2.0)
- LYToolsKit/Foundation (0.2.0)
- LYToolsKit/UI (0.2.0)
- LYToolsKit/Utility (0.2.0):
- LYToolsKit (0.3.0):
- LYToolsKit/Foundation (= 0.3.0)
- LYToolsKit/UI (= 0.3.0)
- LYToolsKit/Utility (= 0.3.0)
- LYToolsKit/Foundation (0.3.0)
- LYToolsKit/UI (0.3.0)
- LYToolsKit/Utility (0.3.0):
- LYToolsKit/UI
- Masonry
- Masonry (1.1.0)
Expand All @@ -22,7 +22,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
LYToolsKit: 5cc581f93e3be006f7fe62b9c896c8d8980883ba
LYToolsKit: fb16e09795c86ddf6afe2aa0f2b36b3a6480afdb
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201

PODFILE CHECKSUM: 65c98e54016424e0cbfc45321fc4dc72ccb68329
Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/LYToolsKit.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

786 changes: 397 additions & 389 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Example/Pods/Target Support Files/LYToolsKit/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LYToolsKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'LYToolsKit'
s.version = '0.2.0'
s.version = '0.3.0'
s.summary = 'LYToolsKit is Foundation|UI|Utility SDK.'

s.homepage = 'https://github.com/yyly/LYToolsKit'
Expand Down
1 change: 1 addition & 0 deletions LYToolsKit/Foundation/LYFoundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import <LYToolsKit/NSString+LYURL.h>
#import <LYToolsKit/NSString+LYJudge.h>
#import <LYToolsKit/NSString+LYUnits.h>
#import <LYToolsKit/NSString+LYCoding.h>

#pragma mark - NSURL

Expand Down
47 changes: 47 additions & 0 deletions LYToolsKit/Foundation/NSString/NSString+LYCoding.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// NSString+LYCoding.h
// 茗玥古城
//
// Created by 似水灵修 on 13-11-11.
// Copyright (c) 2013年 MingYueGuCheng. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
* 终端测试指令
*
* BASE64编码(abc)
* $ echo -n abc | base64
*
* BASE64解码(YWJj,abc的编码)
* $ echo -n YWJj | base64 -D
*/
@interface NSString(LYBase64)

- (instancetype)ly_base64Encode;
- (instancetype)ly_base64Decode;

@end

/**
* 终端测试指令
* 加密abc字符串:
* MD5:
* $ echo -n abc | openssl md5
* SHA1:
* $ echo -n abc | openssl sha1
* SHA256:
* $ echo -n abc | openssl sha -sha256
* SHA512:
* $ echo -n abc | openssl sha -sha512
*/
@interface NSString(LYHash)

- (instancetype)ly_md5String;
- (instancetype)ly_sha1String;
- (instancetype)ly_sha256String;
- (instancetype)ly_sha512String;

@end

NS_ASSUME_NONNULL_END
73 changes: 73 additions & 0 deletions LYToolsKit/Foundation/NSString/NSString+LYCoding.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// NSString+LYCoding.m
// 茗玥古城
//
// Created by 似水灵修 on 13-11-11.
// Copyright (c) 2013年 MingYueGuCheng. All rights reserved.
//
#import "NSString+LYCoding.h"
#import <CommonCrypto/CommonDigest.h>

@implementation NSString(LYBase64)

- (instancetype)ly_base64Encode {
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding];
return [data base64EncodedStringWithOptions:0];
}

- (instancetype)ly_base64Decode {
NSData *data = [[NSData alloc] initWithBase64EncodedString:self options:0];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}

@end

@implementation NSString(LYHash)

- (instancetype)ly_md5String {
const char *str = self.UTF8String;
int length = (int)strlen(str);
unsigned char bytes[CC_MD5_DIGEST_LENGTH];
CC_MD5(str, length, bytes);

return [self ly_stringFromBytes:bytes length:CC_MD5_DIGEST_LENGTH];
}

- (instancetype)ly_sha1String {
const char *str = self.UTF8String;
int length = (int)strlen(str);
unsigned char bytes[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(str, length, bytes);

return [self ly_stringFromBytes:bytes length:CC_SHA1_DIGEST_LENGTH];
}

- (instancetype)ly_sha256String {
const char *str = self.UTF8String;
int length = (int)strlen(str);
unsigned char bytes[CC_SHA256_DIGEST_LENGTH];
CC_SHA256(str, length, bytes);

return [self ly_stringFromBytes:bytes length:CC_SHA256_DIGEST_LENGTH];
}

- (instancetype)ly_sha512String {
const char *str = self.UTF8String;
int length = (int)strlen(str);
unsigned char bytes[CC_SHA512_DIGEST_LENGTH];
CC_SHA512(str, length, bytes);

return [self ly_stringFromBytes:bytes length:CC_SHA512_DIGEST_LENGTH];
}

- (NSString *)ly_stringFromBytes:(unsigned char *)bytes length:(int)length {
NSMutableString *strM = [NSMutableString string];

for (int i = 0; i < length; i++) {
[strM appendFormat:@"%02x", bytes[i]];
}

return [strM copy];
}

@end
24 changes: 24 additions & 0 deletions LYToolsKit/UI/UI/UIViewExt/UIBarButtonItem+LYExt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UIBarButtonItem+LYExt.h
// 茗玥古城
//
// Created by 似水灵修 on 13-11-11.
// Copyright (c) 2013年 MingYueGuCheng. All rights reserved.

#import <UIKit/UIKit.h>

@interface UIBarButtonItem (LYExt)
/**
快速创建
@param nImageName 普通状态图片
@param hImageName 高亮状态图片
@param target 回调对象
@param action 回调方法
@return 返回BarButtonItem对象
*/
+ (UIBarButtonItem *)ly_itemWithNormalImageName:(NSString *)nImageName
highImageName:(NSString *)hImageName
target:(id)target
action:(SEL)action;
@end
31 changes: 31 additions & 0 deletions LYToolsKit/UI/UI/UIViewExt/UIBarButtonItem+LYExt.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// UIBarButtonItem+Item.m
// 茗玥古城
//
// Created by 似水灵修 on 13-11-11.
// Copyright (c) 2013年 MingYueGuCheng. All rights reserved.
//

#import "UIBarButtonItem+LYExt.h"

@implementation UIBarButtonItem (LYExt)

/**
* 设置导航栏按钮
*
* @param nImageName 普通状态图片
* @param hImageName 高亮状态图片
* @param action 响应事件
*/
+ (UIBarButtonItem *)ly_itemWithNormalImageName:(NSString *)nImageName highImageName:(NSString *)hImageName target:(id)target action:(SEL)action {
UIImage *nImage = nImageName.length ? [UIImage imageNamed:nImageName] : nil;
UIImage *hImage = hImageName.length ? [UIImage imageNamed:hImageName] : nil;

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:nImage forState:UIControlStateNormal];
[btn setBackgroundImage:hImage forState:UIControlStateHighlighted];
[btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
return [[UIBarButtonItem alloc] initWithCustomView:btn];
}

@end
3 changes: 3 additions & 0 deletions LYToolsKit/Utility/UIButton/LYHyperlinksButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
// 超链接按钮

#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN

@interface LYHyperlinksButton : UIButton
@property (strong, nonatomic) UIColor *lineColor; /**< 下划线颜色 */
@end

NS_ASSUME_NONNULL_END

0 comments on commit 2ab2375

Please sign in to comment.