佚名通过本文主要向大家介绍了oc代码转swift,oc转swift,swift和oc的区别,oc swift,oc调用swift等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 一句oc代码转成swift
描述:
NSLog(@"reslut = %@",resultDic);
}];
就是这句,不知道那个callback后面怎么转,这样做 AlipaySDK.defaultService().payOrder(orderString, fromScheme: appScheme, callback: nil)可以编译通过,但肯定不正确,求教,谢谢
解决方案1:
self.contenButton = {
let tempButton = UIButton(frame:CGRectZero)
tempButton.addTarget(self, action: "hideMenuViewController", forControlEvents: .TouchUpInside)
return tempButton
}(); 解决方案2:
请问下面代码怎么转换?
self.contentButton = ({
UIButton *button = [[UIButton alloc] initWithFrame:CGRectNull];
[button addTarget:self action:@selector(hideMenuViewController) forControlEvents:UIControlEventTouchUpInside];
button;
}); 解决方案4:
描述:
本帖最后由 wsxcy66668888 于 2015-05-20 13:53:51 编辑
swiftcallback
[[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {NSLog(@"reslut = %@",resultDic);
}];
就是这句,不知道那个callback后面怎么转,这样做 AlipaySDK.defaultService().payOrder(orderString, fromScheme: appScheme, callback: nil)可以编译通过,但肯定不正确,求教,谢谢
解决方案1:
self.contenButton = {
let tempButton = UIButton(frame:CGRectZero)
tempButton.addTarget(self, action: "hideMenuViewController", forControlEvents: .TouchUpInside)
return tempButton
}(); 解决方案2:
let button: UIButton = UIButton(frame: CGRectNull)
button.addTarget(self, action: "hideMenuViewController", forControlEvents: UIControlEventTouchUpInside)
button
self.contentButton = button
oc的block 在swift中用闭包,尝试AlipaySDK.defaultService().payOrder(orderString, fromScheme: appScheme, callback: {
(resultDic:NSDictionary!) ->Void in
println("result= \(resultDic)")
})
请问下面代码怎么转换?
self.contentButton = ({
UIButton *button = [[UIButton alloc] initWithFrame:CGRectNull];
[button addTarget:self action:@selector(hideMenuViewController) forControlEvents:UIControlEventTouchUpInside];
button;
}); 解决方案4:
oc的block 在swift中用闭包,尝试
AlipaySDK.defaultService().payOrder(orderString, fromScheme: appScheme, callback: {
(resultDic:NSDictionary!) ->Void in
println("result= \(resultDic)")
})