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
#!/bin/sh | |
# | |
# BUILD PLATFORM SPECIFIC FRAMEWORKS | |
# | |
# rember before use: chmod +x create_xcframework.sh | |
# iOS devices | |
xcodebuild archive \ | |
-scheme "MyLibrary iOS" \ |
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
public extension String { | |
/// Search a json key/value and return the relative full json object | |
func searchAndDecode<T: Codable>(key: String?, value: String?) -> [T]? { | |
guard let key, let value else { return nil } | |
let pattern = "\\{[^}]*?\"\(key)\".*\"\(value)\"[^}]*\\}" | |
guard let list = self.replacingOccurrences(of: "{", with: "{\n").capture(pattern: pattern), | |
let data = "[\(list.joined(separator: ","))]".data(using: .utf8), | |
let items = try? JSONDecoder().decode([T].self, from: data) | |
else { return nil } | |
return items |
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
import Foundation | |
class WeakRef<T> where T: AnyObject { | |
private let queue = DispatchQueue(label: "ThreadSafeWeakRef.queue", attributes: .concurrent) | |
private(set) weak var _object: T? | |
weak var object: T? { | |
var result: T? |
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
// recognized content-type | |
private let data_sign = [ | |
"7z¼¯'": "application/x-7z-compressed", | |
"AIFF": "audio/x-aiff", | |
"AVI": "video/x-msvideo", | |
"BM": "image/bmp", | |
"BZh": "application/x-bzip2", | |
"MSCF": "application/vnd.ms-cab-compressed", | |
"ITSF": "application/vnd.ms-htmlhelp", | |
"!<arch>": "application/x-debian-package", |
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
extension Decodable | |
{ | |
init(_ data: Data) throws { | |
self = try JSONDecoder().decode(Self.self, from: data) | |
} | |
} | |
extension Data | |
{ | |
func toObject<T>() throws -> T? |
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
class ConsoleLog { | |
// to log even when a device is not connected to xcode | |
// it generates a file that you can then download from the Organizer | |
// select Devices -> select device -> select app -> Dowload container | |
// after you can able show the content of file and you navigate | |
// to Document folder for get the log file. | |
static func logToFile() { | |
#if DEBUG | |
if !self.isXcode() { |
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
// | |
// ENBaseObject.swift | |
// | |
import OHMySQL // https://github.com/oleghnidets/OHMySQL | |
import EVReflection // https://github.com/evermeer/EVReflection | |
class ENBaseObject: EVObject, OHMappingProtocol { | |
static var table: String { | |
return "\(String(describing: self).dropFirst(2))" |
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
// Swift 4 | |
extension String { | |
func toAttributedString(color: UIColor?, font: UIFont?) -> NSAttributedString { | |
do { | |
var string = self | |
if color != nil, font != nil { | |
string = """ |
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
// file: "UIWebView+Height.h" | |
#import <UIKit/UIKit.h> | |
typedef void(^WebViewContentLoaded)(NSString *html, CGSize scrollSize); | |
@interface UIWebView (Height) <UIWebViewDelegate> | |
@property (nonatomic, copy) WebViewContentLoaded webLoadedBlock; |
NewerOlder