-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from iiiCeBlink/dev-load
Fix #51 and remove load method referenced from objc files (compatibility with Swift 5 and Xcode 10.2)
- Loading branch information
Showing
7 changed files
with
64 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// SwiftySelfAwareHelper.swift | ||
// Wormholy | ||
// | ||
// Created by Kealdish on 2019/2/28. | ||
// Copyright © 2019 Wormholy. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
protocol SelfAware: class { | ||
static func awake() | ||
} | ||
|
||
struct CustomSelfAwareHelper { | ||
|
||
static func harmlessFunction() { | ||
|
||
// Get all class list through runtime | ||
let typeCount = Int(objc_getClassList(nil, 0)) | ||
let types = UnsafeMutablePointer<AnyClass>.allocate(capacity: typeCount) | ||
let autoreleasingTypes = AutoreleasingUnsafeMutablePointer<AnyClass>(types) | ||
objc_getClassList(autoreleasingTypes, Int32(typeCount)) | ||
|
||
for index in 0 ..< typeCount { | ||
(types[index] as? SelfAware.Type)?.awake() | ||
} | ||
|
||
types.deallocate() | ||
} | ||
} | ||
|
||
extension UIApplication { | ||
|
||
private static let runOnce: Void = { | ||
CustomSelfAwareHelper.harmlessFunction() | ||
}() | ||
|
||
override open var next: UIResponder? { | ||
// Called before applicationDidFinishLaunching | ||
UIApplication.runOnce | ||
return super.next | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters