fix(extend-ios-with-swift): #55 add @objc attr
diff --git a/docs/guide/extend/extend-ios-with-swift.md b/docs/guide/extend/extend-ios-with-swift.md
index 1671a40..de0e277 100644
--- a/docs/guide/extend/extend-ios-with-swift.md
+++ b/docs/guide/extend/extend-ios-with-swift.md
@@ -54,17 +54,22 @@
- WXSwiftTestModule.swift
- ```
+ ```swift
import Foundation
public extension WXSwiftTestModule {
- public func printSome(someThing:String, callback:WXModuleCallback) {
- print(someThing)
- callback(someThing)
- }
+ @objc(printSome:callback:)
+ public func printSome(someThing:String, callback:WXModuleCallback) {
+ print(someThing)
+ callback(someThing)
+ }
}
```
- we need to expose `WXSwiftTestModule` `WXModuleCallback` in `WeexDemo-Bridging-Header` as our `Objective-C` need to access them
+ we need to expose `WXSwiftTestModule` `WXModuleCallback` in `WeexDemo-Bridging-Header` as our `Objective-C` need to access them.
+
+ Attention: Please add the `@objc` attribute to the method in the Swift file to avoid the error for the method cannot be found.
+
+
- WeexDemo-Bridging-Header.h
diff --git a/docs/zh/guide/extend/extend-ios-with-swift.md b/docs/zh/guide/extend/extend-ios-with-swift.md
index f4ebeb4..2ac0db3 100644
--- a/docs/zh/guide/extend/extend-ios-with-swift.md
+++ b/docs/zh/guide/extend/extend-ios-with-swift.md
@@ -51,17 +51,21 @@
扩展 OC 的类 `WXSwiftTestModule`,增加了一个方法,这个方法就是我们要暴露出来,在 js 中可以调到的
- WXSwiftTestModule.swift
- ```
+ ```swift
import Foundation
public extension WXSwiftTestModule {
- public func printSome(someThing:String, callback:WXModuleCallback) {
- print(someThing)
- callback(someThing)
- }
+ @objc(printSome:callback:)
+ public func printSome(someThing:String, callback:WXModuleCallback) {
+ print(someThing)
+ callback(someThing)
+ }
}
```
- `WXSwiftTestModule` 和`WXModuleCallback` 因为是 OC 的,需要在 `WeexDemo-Bridging-Header` 中暴露
+ `WXSwiftTestModule` 和`WXModuleCallback` 因为是 OC 的,需要在 `WeexDemo-Bridging-Header` 中暴露。
+
+ 注意:请在 Swift 文件中为方法添加 `@objc` 修饰符,避免找不到方法的报错。
+
- WeexDemo-Bridging-Header.h中
```