Skip to content

Commit 915fc46

Browse files
authored
Update README.md
1 parent 2bd4754 commit 915fc46

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ NSObject+MJKeyValue.h NSObject+MJKeyValue.m
8181
>
8282
> - [Usage - SwiftModelTests.swift](MJExtensionTests/SwiftModelTests.swift)
8383
84+
```swift
85+
@objc(MJTester)
86+
@objcMembers
87+
class MJTester: NSObject {
88+
// make sure to use `dynamic` attribute for basic type & must use as Non-Optional & must set initial value
89+
dynamic var isSpecialAgent: Bool = false
90+
dynamic var age: Int = 0
91+
92+
var name: String?
93+
var identifier: String?
94+
}
95+
```
96+
8497
1. `@objc` or `@objcMembers` attributes should be added to class or property for declaration of Objc accessibility [在 Swift4 之后, 请在属性前加 `@objc` 修饰或在类前增加 `@objcMembers`. 以保证 Swift 的属性能够暴露给 Objc 使用. ]
8598
2. If you let `Bool` & `Int` as property type, make sure that using `dynamic` to attribute it. It must be `Non-Optional` type and assign `a default value`.
8699

0 commit comments

Comments
 (0)