Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/osfunapps/ostools-ios
https://github.com/osfunapps/ostools-ios
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/osfunapps/ostools-ios
- Owner: osfunapps
- License: mit
- Created: 2020-08-06T14:23:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T11:28:13.000Z (30 days ago)
- Last Synced: 2024-11-27T12:12:30.480Z (30 days ago)
- Language: Swift
- Size: 182 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OsTools
[![CI Status](https://img.shields.io/travis/osfunapps/OsTools.svg?style=flat)](https://travis-ci.org/osfunapps/OsTools)
[![Version](https://img.shields.io/cocoapods/v/OsTools.svg?style=flat)](https://cocoapods.org/pods/OsTools)
[![License](https://img.shields.io/cocoapods/l/OsTools.svg?style=flat)](https://cocoapods.org/pods/OsTools)
[![Platform](https://img.shields.io/cocoapods/p/OsTools.svg?style=flat)](https://cocoapods.org/pods/OsTools)This module serves as a foundemental toolkit to osApps iOS developing.
## Example functions and signatures
```
/// Will run a function after a delay. The delayed function will run on the main thread
public static func asyncMainTimedFunc(_ funcc: @escaping (() -> ()), _ seconds: Int = 0, millis: Int = 0) -> DispatchWorkItem {
let task = DispatchWorkItem {
funcc()
}
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(seconds) + .milliseconds(millis), execute: task)
return task
}/// Will run a function after a delay. The delayed function will run on a background dq
public static func asyncTimedFunc(_ funcc: @escaping (() -> ()),
seconds: Int = 0,
millis: Int = 0,
qos: DispatchQoS.QoSClass = .utility) -> DispatchWorkItem {
let task = DispatchWorkItem {
funcc()
}
DispatchQueue.global(qos: qos).asyncAfter(deadline: DispatchTime.now() + .seconds(seconds) + .milliseconds(millis), execute: task)
return task
}/// Wll run a function after a delay on the main thread
public static func asyncMainTimedTask(task: DispatchWorkItem,
seconds: Int = 0,
millis: Int = 0) {
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(seconds) + .milliseconds(millis), execute: task)
}/// Wll run a function after a delay on a background thread
public static func asyncTimedTask(task: DispatchWorkItem,
seconds: Int = 0,
millis: Int = 0,
qos: DispatchQoS.QoSClass = .utility) {
DispatchQueue.global(qos: qos).asyncAfter(deadline: DispatchTime.now() + .seconds(seconds) + .milliseconds(millis), execute: task)
}/// Will return true if the char is of a language
public static func isLanguageChar(possibleChar: String) -> Bool {
if(possibleChar.count > 1){
return false
}
return (possibleChar.range(of: "[\\p{Alnum},\\s#\\-.]+", options: .regularExpression, range: nil, locale: nil) != nil)
}/// Will return the top most view controller in the back stack
public static func getLastViewController(_ viewController: UIViewController) -> UIViewController? {
let controllersCount = viewController.navigationController?.viewControllers.count
if(controllersCount != nil) {
return viewController.navigationController?.viewControllers[controllersCount! - 1]
} else {
return nil
}
}
```## Installation
OsTools is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'OsTools'
```## Author
osApps, [email protected]
## License
OsTools is available under the MIT license. See the LICENSE file for more info.