1,字符串加@:
不加@的是C语言字符串。
加@的代表的是OC的NSString
http://www.jikexueyuan.com/course/71_2.html
2,setValuesForKeysWithDictionary
http://www.cnblogs.com/YouXianMing/p/3641304.html
3,instancetype只能作为返回值,不能像id那样作为参数。
4,UIActionSheet
- (IBAction)showSheet:(id)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"title,nil时不显示"
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:@"确定"
otherButtonTitles:@"第一项", @"第二项",nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
}
转成Swift
直接调用ActionSheet的 init(title: String?, delegate: UIActionSheetDelegate?, cancelButtonTitle: String?, destructiveButtonTitle: String?)
方法不行。必须 分开写才行。
actionSheet = UIActionSheet()
actionSheet.title = Str_label_goods_category
actionSheet.delegate = self
for (var k = 0 ;k < str.count ; k++ )
{
actionSheet.addButtonWithTitle(str[k])
}
actionSheet.actionSheetStyle = UIActionSheetStyle.BlackOpaque
actionSheet.showInView(self)
5,oc 的文件导入swift项目中
如果OC的代码非arc的,需要在compile source 里面给该文件更改Compiler Flags为-fno-objc-arc
arc的不需要。
然后在supporting Files里面的jj-Bridging-Header.h里面加入#import<*****.h> (#include"***.h"也行)
6,oc项目调用swift
oc头部引用#import"项目名-swift.h"