Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用swift写的时候,报Use of unresolved identifier '$' #39

Open
water2891 opened this issue Dec 30, 2015 · 1 comment
Open

用swift写的时候,报Use of unresolved identifier '$' #39

water2891 opened this issue Dec 30, 2015 · 1 comment

Comments

@water2891
Copy link

新人,直接学的swift,用了桥接把samurai-native引进来了,用swift重写catalog的,其他都好,就是Test_UITextField里报Use of unresolved identifier '$',求大神给个解决方法

@water2891
Copy link
Author

尝试了无数次,暂时解决了一下,但不优雅:

1.swift和objc混用的时候
typedef SamuraiHtmlRenderQuery * (^SamuraiHtmlRenderQueryBlockN)( id first, ... );
这一句里的...会影响到,swift里不能调用ATTR、SET_CLASS、ADD_CLASS这几个大写的方法,把几个...去掉以后,再编译,就能调了

2.“$”还是不能用,试着用了__dollar(self.t1!),结果返回值是个function类型,尝试__dollar(self.t1!)(self.t1!)后,顺利得到SamuraiHtmlRenderQuery类型,之后使用
__dollar(self.t1!)(self.t1!).ADD_CLASS("error")
可以顺利让文本框变红

3.尝试用网上说的@asmname赋别名,失败
@asmname("__dollar") func $(context:AnyObject) -> SamuraiHtmlRenderQueryBlockN
没办法,只能用个func包了一下
func $(context:AnyObject) -> SamuraiHtmlRenderQuery{
return __dollar(self)(context)
}
总算可以调用 $(self.t1!).ADD_CLASS("error")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant