我正在尝试在 Swift 项目中使用 SDWebImage。我将 SDWebImage 库文件夹拖放到我的 Swift 项目中,并创建了一个名为 listingApp-Bridging-Header.h 的桥接头文件
然后我将头文件导入到我的 Swift 文件中;像这样进口
import UIImageView+WebCache.h
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell : TableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as! TableViewCell
let strTitle : NSString = arrDict[indexPath.row].valueForKey("clip_name") as! NSString
cell.clipName.text = strTitle as String
cell.videoImage sd_setImageWithURL=NSURL URLWithString,[NSString stringWithFormat:@"%@%@",K_Server_imageurl,[record valueForKey:@"clip_image_path"]];
return cell
}
它给我一个错误说 add ; before +
如何将上面的文件正确导入到我的 Swift 项目中?
最佳答案
在桥接头文件中导入头文件名时需要用引号引起来。像这样:
#import "UIImageView+WebCache.h";
这与在objc中导入头文件的语法完全一样。
关于ios - 如何在swift项目中导入objective c头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38429855/