Skip to content

Commit

Permalink
Added more extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Nov 21, 2024
1 parent 4f47dcb commit 0148d12
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Sources/SwiftBoost/CoreGraphics/Extensions/CGFloatExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#if canImport(CoreGraphics)
import CoreGraphics

extension CGFloat {

public func rounded(to places: Int) -> CGFloat {
let divisor = pow(10.0, CGFloat(places))
return (self * divisor).rounded() / divisor
}
}
#endif
7 changes: 7 additions & 0 deletions Sources/SwiftBoost/Foundation/Extensions/ArrayExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ public extension Array where Element: Equatable {
return result
}
}

public extension ArraySlice {

var array: [Element] {
return Array(self)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Foundation

public extension NotificationCenter {
extension NotificationCenter {

func post(name: NSNotification.Name) {
public func addObserver(_ names: NSNotification.Name..., using block: @escaping @Sendable (Notification) -> Void) {
for name in names {
NotificationCenter.default.addObserver(forName: name, object: nil, queue: nil, using: block)
}
}

public func post(name: NSNotification.Name) {
post(name: name, object: nil)
}
}

0 comments on commit 0148d12

Please sign in to comment.