Skip to content

Commit

Permalink
OC版本GCD定时器
Browse files Browse the repository at this point in the history
  • Loading branch information
amenzone committed Aug 15, 2023
1 parent b083c84 commit 251c041
Show file tree
Hide file tree
Showing 36 changed files with 1,560 additions and 14 deletions.
8 changes: 4 additions & 4 deletions Example/OCTimer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

/* Begin PBXFileReference section */
47BB1179BF5DFE331577EC4F /* Pods-OCTimer_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OCTimer_Tests.release.xcconfig"; path = "Target Support Files/Pods-OCTimer_Tests/Pods-OCTimer_Tests.release.xcconfig"; sourceTree = "<group>"; };
4EC4E721A46A5693C86620F2 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
4EC4E721A46A5693C86620F2 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
5C4BC834D741197AE700A0ED /* Pods-OCTimer_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OCTimer_Example.debug.xcconfig"; path = "Target Support Files/Pods-OCTimer_Example/Pods-OCTimer_Example.debug.xcconfig"; sourceTree = "<group>"; };
6003F58A195388D20070C39A /* OCTimer_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OCTimer_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
6003F58D195388D20070C39A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand All @@ -62,9 +62,9 @@
71719F9E1E33DC2100824A3D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
B4AF5641C62EF8C64214A022 /* Pods_OCTimer_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OCTimer_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C9265083C56C18F9D277F712 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; name = README.md; path = ../README.md; sourceTree = "<group>"; };
C9265083C56C18F9D277F712 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
CB4AAB6E02F1020814707930 /* Pods-OCTimer_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OCTimer_Example.release.xcconfig"; path = "Target Support Files/Pods-OCTimer_Example/Pods-OCTimer_Example.release.xcconfig"; sourceTree = "<group>"; };
D79D8DB06C271D4ABE407F5D /* OCTimer.podspec */ = {isa = PBXFileReference; includeInIndex = 1; name = OCTimer.podspec; path = ../OCTimer.podspec; sourceTree = "<group>"; };
D79D8DB06C271D4ABE407F5D /* OCTimer.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = OCTimer.podspec; path = ../OCTimer.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
E657A48F1FFD5EE33DCEFC4B /* Pods_OCTimer_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OCTimer_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F104B7ED209C80FBC485F566 /* Pods-OCTimer_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OCTimer_Tests.debug.xcconfig"; path = "Target Support Files/Pods-OCTimer_Tests/Pods-OCTimer_Tests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -193,7 +193,6 @@
F104B7ED209C80FBC485F566 /* Pods-OCTimer_Tests.debug.xcconfig */,
47BB1179BF5DFE331577EC4F /* Pods-OCTimer_Tests.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -258,6 +257,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down
10 changes: 10 additions & 0 deletions Example/OCTimer.xcworkspace/contents.xcworkspacedata

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
32 changes: 25 additions & 7 deletions Example/OCTimer/OCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,41 @@
//

#import "OCViewController.h"
#import "OCTimer.h"

@interface OCViewController ()

@property (copy, nonatomic) NSString *task;
//@property (copy, nonatomic) NSString *task2;
@end

@implementation OCViewController

- (void)viewDidLoad
{
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

// 接口设计
self.task = [OCTimer execTask:self
selector:@selector(doTask)
start:2.0
interval:1.0
repeats:YES
async:YES];
// 接口设计2 repeats:NO 不需要调用cancelTask
/*self.task2 = [OCTimer execTask:^{
NSLog(@"执行任务 - %@", [NSThread currentThread]);
} start:2.0 interval:1 repeats:NO async:NO];*/
}

- (void)didReceiveMemoryWarning
- (void)doTask
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
NSLog(@"DoTask - %@", [NSThread currentThread]);
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[OCTimer cancelTask:self.task];
}


@end

16 changes: 16 additions & 0 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- OCTimer (0.1.0)

DEPENDENCIES:
- OCTimer (from `../`)

EXTERNAL SOURCES:
OCTimer:
:path: "../"

SPEC CHECKSUMS:
OCTimer: b020f64a4eeba959fea4e32e8bd181a4e60db387

PODFILE CHECKSUM: 436a24aba658447b9f27416296e2f32e44fbd3f4

COCOAPODS: 1.12.0
22 changes: 22 additions & 0 deletions Example/Pods/Local Podspecs/OCTimer.podspec.json

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

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

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

Loading

0 comments on commit 251c041

Please sign in to comment.