Skip to content

Commit ffe1dfd

Browse files
author
JmoVxia
committed
增加自定义相机
1 parent fb701de commit ffe1dfd

File tree

297 files changed

+8563
-7757
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+8563
-7757
lines changed

CLDemo-OC/CLDemo-OC.xcodeproj/xcuserdata/jmovxia.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CLDemo-OC.xcscheme_^#shared#^_</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>18</integer>
10+
<integer>23</integer>
1111
</dict>
1212
</dict>
1313
</dict>

CLDemo-Swift/CLDemo-Swift.xcodeproj/project.pbxproj

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
5B0DC71E26CA4AE400909BF2 /* CLHoneycombCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B0DC71D26CA4AE400909BF2 /* CLHoneycombCustomCell.swift */; };
2525
5B0FB9D828FFF87A001D012B /* CLCalendarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B0FB9D728FFF87A001D012B /* CLCalendarController.swift */; };
2626
5B1C366F26841FAF00D777EB /* CLPermissionInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1C366D26841FAF00D777EB /* CLPermissionInterface.swift */; };
27-
5B1C367026841FAF00D777EB /* CLPermissions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1C366E26841FAF00D777EB /* CLPermissions.swift */; };
27+
5B1C367026841FAF00D777EB /* CLPermissionsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1C366E26841FAF00D777EB /* CLPermissionsManager.swift */; };
2828
5B3309E228FFFB23000D44DF /* CLCalendarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B3309D828FFFB22000D44DF /* CLCalendarModel.swift */; };
2929
5B3309E328FFFB23000D44DF /* CLCalendarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B3309D928FFFB22000D44DF /* CLCalendarCell.swift */; };
3030
5B3309E428FFFB23000D44DF /* CLCalendarLayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B3309DA28FFFB23000D44DF /* CLCalendarLayoutAttributes.swift */; };
@@ -152,6 +152,7 @@
152152
5B83980B26A1673700FD1D3C /* CLTiledFlipRetroTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B83980A26A1673700FD1D3C /* CLTiledFlipRetroTransition.swift */; };
153153
5B83980D26A1678500FD1D3C /* CLTiledFlipRetroPushTransitionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B83980C26A1678500FD1D3C /* CLTiledFlipRetroPushTransitionController.swift */; };
154154
5B9057A72B46549A003E3B1C /* CLSafeArrayDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B9057A62B46549A003E3B1C /* CLSafeArrayDictionary.swift */; };
155+
5B91B27F2B83300300272CA1 /* CLCaptureController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B91B27E2B83300300272CA1 /* CLCaptureController.swift */; };
155156
5B9756A226C64FFA006C0841 /* HomePage.json in Resources */ = {isa = PBXBuildFile; fileRef = 5B9756A126C64FFA006C0841 /* HomePage.json */; };
156157
5B988AC329FB73680076379C /* CLPopupCalendarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B988AC229FB73680076379C /* CLPopupCalendarController.swift */; };
157158
5B9E321F29CDDA6500D96638 /* CLMultiValueController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B9E321E29CDDA6500D96638 /* CLMultiValueController.swift */; };
@@ -174,6 +175,7 @@
174175
5BC9911B26C65DBD0026B6FF /* CLHoneycombCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC9911A26C65DBD0026B6FF /* CLHoneycombCollectionViewController.swift */; };
175176
5BC9911E26C65E070026B6FF /* CLHoneycombLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC9911D26C65E070026B6FF /* CLHoneycombLayout.swift */; };
176177
5BC9912126C65E3A0026B6FF /* CLHoneycombCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC9912026C65E3A0026B6FF /* CLHoneycombCollectionViewCell.swift */; };
178+
5BCBC30A2B512C7D00863AF2 /* CLCarouselPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCBC3092B512C7D00863AF2 /* CLCarouselPageControl.swift */; };
177179
5BD0434326832D3F0054F2B4 /* CLBreakPointResumeOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD0433E26832D3F0054F2B4 /* CLBreakPointResumeOperation.swift */; };
178180
5BD0434426832D3F0054F2B4 /* CLBreakPointResumeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD0433F26832D3F0054F2B4 /* CLBreakPointResumeManager.swift */; };
179181
5BD0434526832D3F0054F2B4 /* CLBreakPointResumeItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD0434026832D3F0054F2B4 /* CLBreakPointResumeItem.swift */; };
@@ -352,7 +354,7 @@
352354
5B0DC71D26CA4AE400909BF2 /* CLHoneycombCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLHoneycombCustomCell.swift; sourceTree = "<group>"; };
353355
5B0FB9D728FFF87A001D012B /* CLCalendarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLCalendarController.swift; sourceTree = "<group>"; };
354356
5B1C366D26841FAF00D777EB /* CLPermissionInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLPermissionInterface.swift; sourceTree = "<group>"; };
355-
5B1C366E26841FAF00D777EB /* CLPermissions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLPermissions.swift; sourceTree = "<group>"; };
357+
5B1C366E26841FAF00D777EB /* CLPermissionsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLPermissionsManager.swift; sourceTree = "<group>"; };
356358
5B3309D828FFFB22000D44DF /* CLCalendarModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLCalendarModel.swift; sourceTree = "<group>"; };
357359
5B3309D928FFFB22000D44DF /* CLCalendarCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLCalendarCell.swift; sourceTree = "<group>"; };
358360
5B3309DA28FFFB23000D44DF /* CLCalendarLayoutAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLCalendarLayoutAttributes.swift; sourceTree = "<group>"; };
@@ -485,6 +487,7 @@
485487
5B83980A26A1673700FD1D3C /* CLTiledFlipRetroTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLTiledFlipRetroTransition.swift; sourceTree = "<group>"; };
486488
5B83980C26A1678500FD1D3C /* CLTiledFlipRetroPushTransitionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLTiledFlipRetroPushTransitionController.swift; sourceTree = "<group>"; };
487489
5B9057A62B46549A003E3B1C /* CLSafeArrayDictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLSafeArrayDictionary.swift; sourceTree = "<group>"; };
490+
5B91B27E2B83300300272CA1 /* CLCaptureController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLCaptureController.swift; sourceTree = "<group>"; };
488491
5B9756A126C64FFA006C0841 /* HomePage.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = HomePage.json; sourceTree = "<group>"; };
489492
5B988AC229FB73680076379C /* CLPopupCalendarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLPopupCalendarController.swift; sourceTree = "<group>"; };
490493
5B9E321E29CDDA6500D96638 /* CLMultiValueController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLMultiValueController.swift; sourceTree = "<group>"; };
@@ -510,6 +513,7 @@
510513
5BC9911A26C65DBD0026B6FF /* CLHoneycombCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLHoneycombCollectionViewController.swift; sourceTree = "<group>"; };
511514
5BC9911D26C65E070026B6FF /* CLHoneycombLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLHoneycombLayout.swift; sourceTree = "<group>"; };
512515
5BC9912026C65E3A0026B6FF /* CLHoneycombCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLHoneycombCollectionViewCell.swift; sourceTree = "<group>"; };
516+
5BCBC3092B512C7D00863AF2 /* CLCarouselPageControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CLCarouselPageControl.swift; sourceTree = "<group>"; };
513517
5BD0433E26832D3F0054F2B4 /* CLBreakPointResumeOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLBreakPointResumeOperation.swift; sourceTree = "<group>"; };
514518
5BD0433F26832D3F0054F2B4 /* CLBreakPointResumeManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLBreakPointResumeManager.swift; sourceTree = "<group>"; };
515519
5BD0434026832D3F0054F2B4 /* CLBreakPointResumeItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CLBreakPointResumeItem.swift; sourceTree = "<group>"; };
@@ -795,13 +799,21 @@
795799
path = CLCalendar;
796800
sourceTree = "<group>";
797801
};
798-
5B1C366C26841FAF00D777EB /* CLPermissions */ = {
802+
5B1C366C26841FAF00D777EB /* CLPermissionsManager */ = {
799803
isa = PBXGroup;
800804
children = (
801805
5B1C366D26841FAF00D777EB /* CLPermissionInterface.swift */,
802-
5B1C366E26841FAF00D777EB /* CLPermissions.swift */,
806+
5B1C366E26841FAF00D777EB /* CLPermissionsManager.swift */,
803807
);
804-
path = CLPermissions;
808+
path = CLPermissionsManager;
809+
sourceTree = "<group>";
810+
};
811+
5B23A65E2B8325F400DC4975 /* CLCaptureController */ = {
812+
isa = PBXGroup;
813+
children = (
814+
5B91B2802B8335D600272CA1 /* Controller */,
815+
);
816+
path = CLCaptureController;
805817
sourceTree = "<group>";
806818
};
807819
5B3309F22900F49F000D44DF /* CLTagsCalculateController */ = {
@@ -954,7 +966,7 @@
954966
5BD4EAFA268184AB00B5284F /* Extension */,
955967
5B39ECD127574B18000FCF67 /* CLHanziToPinyin */,
956968
5B58C56A26846B34001736D7 /* CLRecorder */,
957-
5B1C366C26841FAF00D777EB /* CLPermissions */,
969+
5B1C366C26841FAF00D777EB /* CLPermissionsManager */,
958970
5B76933726841E14008BB92B /* CLGCDTimer */,
959971
5B3309FF2901180C000D44DF /* CLTableView */,
960972
5BD4EB7926818A1300B5284F /* CLLogManager */,
@@ -1370,6 +1382,7 @@
13701382
5B800435268194B1000E39AC /* CLHomePageController */,
13711383
5B3CC416291EA8D000568D77 /* CLLineChartController */,
13721384
5BBFE84A29DE53BF00A5AC34 /* CLExcelController */,
1385+
5B23A65E2B8325F400DC4975 /* CLCaptureController */,
13731386
5BC9911926C65D780026B6FF /* CLHoneycombController */,
13741387
5BEF4CFA2881011A00A15433 /* CLTruncationController */,
13751388
5B9E321D29CDDA4B00D96638 /* CLMultiValueController */,
@@ -1561,6 +1574,14 @@
15611574
path = CLTiledFlipRetroTransition;
15621575
sourceTree = "<group>";
15631576
};
1577+
5B91B2802B8335D600272CA1 /* Controller */ = {
1578+
isa = PBXGroup;
1579+
children = (
1580+
5B91B27E2B83300300272CA1 /* CLCaptureController.swift */,
1581+
);
1582+
path = Controller;
1583+
sourceTree = "<group>";
1584+
};
15641585
5B988AC129FB73380076379C /* CLPopupCalendarController */ = {
15651586
isa = PBXGroup;
15661587
children = (
@@ -2132,6 +2153,7 @@
21322153
children = (
21332154
5BE66817268475940095F82E /* CLCarouselView.swift */,
21342155
5BE66818268475940095F82E /* CLCarouselCell.swift */,
2156+
5BCBC3092B512C7D00863AF2 /* CLCarouselPageControl.swift */,
21352157
);
21362158
path = CLCarouselView;
21372159
sourceTree = "<group>";
@@ -2290,8 +2312,9 @@
22902312
5B4895EA268097510046AF31 /* Project object */ = {
22912313
isa = PBXProject;
22922314
attributes = {
2315+
BuildIndependentTargetsInParallel = YES;
22932316
LastSwiftUpdateCheck = 1250;
2294-
LastUpgradeCheck = 1250;
2317+
LastUpgradeCheck = 1520;
22952318
TargetAttributes = {
22962319
5B4895F1268097510046AF31 = {
22972320
CreatedOnToolsVersion = 12.5;
@@ -2445,6 +2468,7 @@
24452468
5B0DC71226CA372400909BF2 /* CLHoneycombView.swift in Sources */,
24462469
5BAABFF92681B36800C2F609 /* CLTitleCellItem.swift in Sources */,
24472470
5BD4EB782681872D00B5284F /* CLPopupBMIInputController.swift in Sources */,
2471+
5B91B27F2B83300300272CA1 /* CLCaptureController.swift in Sources */,
24482472
5B76932A26841C70008BB92B /* CLChatImageCell.swift in Sources */,
24492473
5BD043A32683302E0054F2B4 /* CLDrawerTransitionDelegate.swift in Sources */,
24502474
5B7692C026841566008BB92B /* CLVernierCaliperHeaderCell.swift in Sources */,
@@ -2491,14 +2515,15 @@
24912515
5B76931626841C70008BB92B /* CLChatRecordView.swift in Sources */,
24922516
5B8397FC26A15BAC00FD1D3C /* CLCircleRetroTransitionController.swift in Sources */,
24932517
5BD4EB19268184AB00B5284F /* UIView+Extension.swift in Sources */,
2494-
5B1C367026841FAF00D777EB /* CLPermissions.swift in Sources */,
2518+
5B1C367026841FAF00D777EB /* CLPermissionsManager.swift in Sources */,
24952519
5B76932226841C70008BB92B /* CLChatEmojiView.swift in Sources */,
24962520
5B39ECD027574AC0000FCF67 /* CLIngredients.swift in Sources */,
24972521
5BD0442626833C7C0054F2B4 /* CLStartsView.swift in Sources */,
24982522
5B0DC70A26CA34C600909BF2 /* CLHoneycombController.swift in Sources */,
24992523
5B0DC71626CA378900909BF2 /* CLHoneycombDelegate.swift in Sources */,
25002524
5B0FB9D828FFF87A001D012B /* CLCalendarController.swift in Sources */,
25012525
5B76932626841C70008BB92B /* CLChatTextView.swift in Sources */,
2526+
5BCBC30A2B512C7D00863AF2 /* CLCarouselPageControl.swift in Sources */,
25022527
5BE6690D26848BE10095F82E /* CLTextViewViewController.swift in Sources */,
25032528
5BD043B1268332880054F2B4 /* CLHistogramConroller.swift in Sources */,
25042529
5BD4EB1B268184AB00B5284F /* UIControl+Extension.swift in Sources */,
@@ -2789,6 +2814,7 @@
27892814
DEBUG_INFORMATION_FORMAT = dwarf;
27902815
ENABLE_STRICT_OBJC_MSGSEND = YES;
27912816
ENABLE_TESTABILITY = YES;
2817+
ENABLE_USER_SCRIPT_SANDBOXING = NO;
27922818
FRAMEWORK_SEARCH_PATHS = "";
27932819
GCC_C_LANGUAGE_STANDARD = gnu11;
27942820
GCC_DYNAMIC_NO_PIC = NO;
@@ -2854,6 +2880,7 @@
28542880
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
28552881
ENABLE_NS_ASSERTIONS = NO;
28562882
ENABLE_STRICT_OBJC_MSGSEND = YES;
2883+
ENABLE_USER_SCRIPT_SANDBOXING = NO;
28572884
FRAMEWORK_SEARCH_PATHS = "";
28582885
GCC_C_LANGUAGE_STANDARD = gnu11;
28592886
GCC_NO_COMMON_BLOCKS = YES;
@@ -2883,6 +2910,7 @@
28832910
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
28842911
CODE_SIGN_STYLE = Automatic;
28852912
DEVELOPMENT_TEAM = YPW3979SPT;
2913+
ENABLE_USER_SCRIPT_SANDBOXING = NO;
28862914
FRAMEWORK_SEARCH_PATHS = "";
28872915
INFOPLIST_FILE = "$(SRCROOT)/CLDemo-Swift/Resource/Info.plist";
28882916
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
@@ -2913,6 +2941,7 @@
29132941
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
29142942
CODE_SIGN_STYLE = Automatic;
29152943
DEVELOPMENT_TEAM = YPW3979SPT;
2944+
ENABLE_USER_SCRIPT_SANDBOXING = NO;
29162945
FRAMEWORK_SEARCH_PATHS = "";
29172946
INFOPLIST_FILE = "$(SRCROOT)/CLDemo-Swift/Resource/Info.plist";
29182947
IPHONEOS_DEPLOYMENT_TARGET = 12.1;

CLDemo-Swift/CLDemo-Swift.xcodeproj/xcshareddata/xcschemes/CLDemo-Swift.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1400"
3+
LastUpgradeVersion = "1520"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

CLDemo-Swift/CLDemo-Swift/CLGCDTimer/CLGCDTimer.swift

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@
99
import UIKit
1010

1111
class CLGCDTimer: NSObject {
12-
typealias actionBlock = (NSInteger) -> Void
12+
public enum State {
13+
case suspended
14+
case resumed
15+
}
16+
1317
/// 执行时间
14-
private var interval: TimeInterval!
18+
public private(set) var interval: TimeInterval!
1519
/// 延迟时间
16-
private var delaySecs: TimeInterval!
20+
public private(set) var delaySecs: TimeInterval!
1721
/// 队列
18-
private var serialQueue: DispatchQueue!
19-
/// 是否重复
20-
private var repeats: Bool = true
21-
/// 响应
22-
private var action: actionBlock?
22+
public private(set) var serialQueue: DispatchQueue!
2323
/// 定时器
24-
private var timer: DispatchSourceTimer!
24+
public private(set) var timer: DispatchSourceTimer!
2525
/// 是否正在运行
26-
private var isRuning: Bool = false
26+
public private(set) var state: State = .suspended
2727
/// 响应次数
28-
private(set) var actionTimes: NSInteger = 0
28+
public private(set) var actionTimes = Int.zero
29+
/// 响应
30+
public private(set) var eventHandler: ((Int) -> Void)?
2931

3032
/// 创建定时器
3133
///
@@ -35,76 +37,51 @@ class CLGCDTimer: NSObject {
3537
/// - queue: 定时器调用的队列,默认主队列
3638
/// - repeats: 是否重复执行,默认true
3739
/// - action: 响应
38-
init(interval: TimeInterval, delaySecs: TimeInterval = 0, queue: DispatchQueue = .main, repeats: Bool = true, action: actionBlock?) {
40+
public init(interval: TimeInterval,
41+
delaySecs: TimeInterval = 0,
42+
queue: DispatchQueue = .main)
43+
{
3944
super.init()
4045
self.interval = interval
4146
self.delaySecs = delaySecs
42-
self.repeats = repeats
4347
serialQueue = queue
44-
self.action = action
4548
timer = DispatchSource.makeTimerSource(queue: serialQueue)
46-
}
47-
48-
/// 替换旧响应
49-
func replaceOldAction(action: actionBlock?) {
50-
guard let action else {
51-
return
49+
timer.schedule(deadline: .now() + delaySecs, repeating: interval)
50+
timer.setEventHandler { [weak self] in
51+
guard let self else { return }
52+
actionTimes += 1
53+
eventHandler?(actionTimes)
5254
}
53-
self.action = action
54-
}
55-
56-
/// 执行一次定时器响应
57-
func responseOnce() {
58-
actionTimes += 1
59-
isRuning = true
60-
action?(actionTimes)
61-
isRuning = false
6255
}
6356

6457
deinit {
65-
cancel()
58+
timer?.setEventHandler(handler: nil)
59+
timer?.cancel()
60+
eventHandler = nil
61+
resume()
6662
}
6763
}
6864

6965
extension CLGCDTimer {
70-
/// 开始定时器
71-
func start() {
72-
timer.schedule(deadline: .now() + delaySecs, repeating: interval)
73-
timer.setEventHandler { [weak self] in
74-
guard let strongSelf = self else {
75-
return
76-
}
77-
strongSelf.actionTimes += 1
78-
strongSelf.action?(strongSelf.actionTimes)
79-
if !strongSelf.repeats {
80-
strongSelf.cancel()
81-
strongSelf.action = nil
82-
}
83-
}
66+
/// 开始
67+
public func start(_ handler: @escaping ((_ count: Int) -> Void)) {
68+
eventHandler = handler
8469
resume()
8570
}
8671

8772
/// 暂停
88-
func suspend() {
89-
if isRuning {
90-
timer.suspend()
91-
isRuning = false
92-
}
73+
public func suspend() {
74+
guard let timer else { return }
75+
guard state != .suspended else { return }
76+
state = .suspended
77+
timer.suspend()
9378
}
9479

9580
/// 恢复定时器
96-
func resume() {
97-
if !isRuning {
98-
timer.resume()
99-
isRuning = true
100-
}
101-
}
102-
103-
/// 取消定时器
104-
func cancel() {
105-
if !isRuning {
106-
resume()
107-
}
108-
timer.cancel()
81+
public func resume() {
82+
guard state != .resumed else { return }
83+
guard let timer else { return }
84+
state = .resumed
85+
timer.resume()
10986
}
11087
}

CLDemo-Swift/CLDemo-Swift/CLHanziToPinyin/CLHanziToPinyin.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ class CLHanziToPinyin {
5454
private(set) lazy var unicodeToPinyinTable: [String: String] = {
5555
guard let resourcePath = Bundle.main.path(forResource: "hanyupinyin", ofType: nil) else { return [:] }
5656
guard let data = try? Data(contentsOf: URL(fileURLWithPath: resourcePath)) else { return [:] }
57-
guard let dictionary = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? [String: String] else { return [:] }
57+
guard let dictionary = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSDictionary.self, NSString.self], from: data) as? [String: String] else { return [:] }
5858
return dictionary
5959
}()
6060

6161
private(set) lazy var sentence: [String: String] = {
6262
guard let resourcePath = Bundle.main.path(forResource: "sentencepinyin", ofType: nil) else { return [:] }
6363
guard let data = try? Data(contentsOf: URL(fileURLWithPath: resourcePath)) else { return [:] }
64-
guard let dictionary = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? [String: String] else { return [:] }
64+
guard let dictionary = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSDictionary.self, NSString.self], from: data) as? [String: String] else { return [:] }
6565
return dictionary
6666
}()
6767

CLDemo-Swift/CLDemo-Swift/CLLogManager/CLLogManager.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
//
88

99
import UIKit
10+
1011
// import DateToolsSwift
1112

1213
@objcMembers class CLLogManager: NSObject {
1314
static let shared = CLLogManager()
14-
private(set) var folderPath: String = .init(format: "%@/%@", pathDocuments, "CLLog")
15+
private(set) var folderPath: String = .init(format: "%@/%@", NSHomeDirectory() + "/Documents", "CLLog")
1516
private var logQueue: DispatchQueue = .init(label: "CLLogManager.logQueue")
1617
private lazy var logFileHandle: FileHandle? = {
1718
let fileManager = FileManager.default

0 commit comments

Comments
 (0)