@@ -89,6 +89,16 @@ public class Utility {
8989 }
9090 }
9191
92+ public class func main( task: @escaping CRVoidBlock ) {
93+ if Thread . isMainThread {
94+ task ( )
95+ } else {
96+ DispatchQueue . main. async {
97+ task ( )
98+ }
99+ }
100+ }
101+
92102 // MARK: - View
93103
94104 public class func presentView( view: UIView , animated: Bool ) {
@@ -102,24 +112,25 @@ public class Utility {
102112 }
103113
104114 // MARK: - storyboard
105- public class func controllerInStoryboard( storyboard: String , identifier: String ) -> UIViewController {
115+
116+ public class func controllerInStoryboard( storyboard: String , identifier: String ) -> UIViewController {
106117 let ontroller = UIStoryboard ( name: storyboard, bundle: nil ) . instantiateViewController ( withIdentifier: identifier)
107118 return ontroller
108119 }
120+
109121 // MARK: - goUrl
110- public class func goStringUrl( _ str: String ? ) {
111122
123+ public class func goStringUrl( _ str: String ? ) {
112124 guard var trimStr = str else { return }
113125 trimStr = trimStr. addingPercentEncoding ( withAllowedCharacters: CharacterSet . urlQueryAllowed) ?? " "
114126 goURL ( URL ( string: trimStr) )
115127 }
116128
117129 public class func goURL( _ url: URL ? ) {
118- guard let trimUrl = url else { return }
130+ guard let trimUrl = url else { return }
119131 if UIApplication . shared. canOpenURL ( trimUrl) {
120132 if #available( iOS 10 . 0 , * ) {
121- UIApplication . shared. open ( trimUrl, options: [ : ] ) { ( _) in
122-
133+ UIApplication . shared. open ( trimUrl, options: [ : ] ) { _ in
123134 }
124135 } else {
125136 UIApplication . shared. openURL ( trimUrl)
0 commit comments