ios objective-c 调swift方法
来源:互联网 发布:c语言心形表白源代码 编辑:程序博客网 时间:2024/06/06 08:42
1、局部方法
例如:
在AbcSwift.swift中
import Alamofireimport Foundationimport RealmSwiftclass AlamofireRequest:NSObject { func getCurrentUserId() -> (String) { init(parameters:String){ } var userId = "" if isCurrentUserExist(){ userId = getCurrentUser().id } return userId }}
在oc中有:
NSString *parameters; AlamofireRequest *fireRequest = [[AlamofireRequest alloc]initWithParameters:parameters];NSString *userId = [fireRequest getCurrentUserId];
2.全局方法
在AbcSwift.swift中:
import Alamofireimport Foundationimport RealmSwiftclass AlamofireRequest:NSObject { func getCurrentUserId() -> (String) { init(parameters:String){ } var userId = "" if isCurrentUserExist(){ userId = getCurrentUser().id } return userId }func creatToken() -> (String) { return createToken() }}func createToken() -> String{ var userId = "" if isCurrentUserExist(){ userId = getCurrentUser().id } let para = "userId=\(userId)&time=\(NSDate().timeIntervalSince1970 as Double)" return DES3Util.encryptText(para)}
道理相同,只是在swift中在局部方法中调用全局方法,然后再oc 中继续调用 为了实现调用全局方法而创建的局部方法,,就可以
0 0
- ios objective-c 调swift方法
- [ios]swift对比objective-c(1)
- [ios]swift对比objective-c(2)
- iOS 从Objective-C到Swift
- iOS 从Objective-C到Swift
- swift对比objective-c
- Swift Objective-C混用
- Objective-C迁移Swift
- Swift调用Objective-C
- Objective-C调用Swift
- Swift调用Objective-C
- Objective-C调用Swift
- Objective-c调用Swift
- iOS入门如何选择Swift和objective-c
- iOS: 学习笔记, Swift与Objective-C混用总结
- 有了Swift,iOS开发者为何仍需掌握Objective-C?
- IOS颜色转换swift和objective-C版
- 盘点一些iOS开发技巧:Swift和Objective-C
- IntelliJ IDEA 创建Servlet,通过urlPatterns配置路径(当然也可以在web.xml中设置)
- HDU 1257 最少拦截系统 (Dilworth定理)
- java注解入门(一)
- 反向迭代器
- HttpURLConnection实现文件下载
- ios objective-c 调swift方法
- HDU Clarke and points
- 深入探讨:linux中遍历文件夹下的所有文件
- 左右连接中where和and的区别
- HTML canvas addColorStop() 、createLinearGradient() 、createRadialGradient() 方法
- k-近邻法
- OE中的bitbake使用
- Linux脚本小程序 时钟
- 恢复二叉搜索树