Skip to content

Commit 72d2662

Browse files
committed
Added array to SPCopying.
1 parent e41ab68 commit 72d2662

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/SparrowKit/Foundation/Classes/SPCopying.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,30 @@
2121

2222
import Foundation
2323

24+
/**
25+
SparrowKit: Custom protocol for make copy of objects.
26+
*/
2427
public protocol SPCopying {
2528

2629
init(instance: Self)
2730
}
2831

2932
extension SPCopying {
3033

34+
/**
35+
SparrowKit: Make copy of object.
36+
*/
3137
public func copyObject() -> Self {
3238
return Self.init(instance: self)
3339
}
3440
}
41+
42+
extension Array where Element: SPCopying {
43+
44+
/**
45+
SparrowKit: Make copy of array objects.
46+
*/
47+
public func copy() -> [Element] {
48+
return self.map { $0.copyObject() }
49+
}
50+
}

0 commit comments

Comments
 (0)