You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|@Access|An easy API to access UserDefaults, NSCache and NSMapTable. |
14
14
||<pre>struct TestAccess {<br> static let cache = NSCache<NSString, AnyObject>()<br><br> // Please make sure the generic type is the same as the type of the variable<br> // Without defalut value<br> @Access<Bool?>(.userDefaults())<br> var isPaidUser: Bool?<br><br> // With default value<br> @Access< Bool>(.userDefaults())<br> var isPaidUser2: Bool = false<br><br> @Access<NSObject?>(.nsCache(TestAccess.cache))<br> var hasPaid: NSObject?<br><br> @Access<NSObject?>(.nsMapTable(TestAccess.mapTable))<br> var hasPaid2: NSObject?<br>}</pre>|
15
15
|@AddAssociatedValueVariable|Add variables to retrieve the associated values|
16
16
||<pre>@AddAssociatedValueVariable<br>enum MyEnum {<br> case first<br> case second(Int)<br> case third(String, Int)<br> case forth(a: String, b: Int), forth2(String, Int)<br> case fifth(() -> Void)<br>}</pre>|
17
-
|@AddPublisher|Generate a Combine publisher to a Combine subject so that we can have a limited ACL for the subject |
17
+
|@AddInit|Generate initialiser for the class/struct/actor. The variables with optional types will have nil as default values. Using `withMock: true` if want to generate mock data. <br> For custmoised data type, it will use `Type.mock`. In case there is no this value, need to define this yourself or use `@Mock` or `@AddInit(withMock: true)` to generate this variable. |
18
+
|@AddPublisher|Generate a Combine publisher to a Combine subject in order to avoid overexposing subject variable |
18
19
||<pre>@AddPublisher<br>private let mySubject = PassthroughSubject<Void, Never>()</pre>|
19
-
|@AddInit|Generate initialiser for the class/struct/actor. the variables with optional types will have nil as default values. Using `withMock: true` if want to generate mock data. <br> For custmoised data type, it will use `Type.mock`. In case there is no this value, need to define this yourself or use `@Mock` or `@AddInit(withMock: true)` to generate this variable. |
20
20
||<pre>@AddInit<br>struct InitStruct {<br> let a: Int<br> let b: Int?<br> let c: (Int?) -> Void<br> let d: ((Int?) -> Void)?<br>}<br>@AddInit(withMock: true)<br>class AStruct {<br> let a: Float<br>}</pre>|
21
21
| #buildDate |Build a Date from components<br>This solution addes in a resultBulder `DateBuilder`, which can be used directly if prefer builder pattern.<br>Note: this is for a simpler API. Please use it with caution in places that require efficiency.|
22
22
||<pre>let date = #buildDate(DateString("03/05/2003", dateFormat: "MM/dd/yyyy"),<br> Date(),<br> Month(10),<br> Year(1909),<br> YearForWeekOfYear(2025))</pre>|
0 commit comments