ios - 如何在swift项目中导入objective c头文件

标签 ios objective-c swift bridging-header

enter image description here

我正在尝试在 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/

相关文章:

c++ - 在 Objective c 中从 NSNotification 中的 Userinfo 转换 NSEnum 失败

ios - NSDateFormatter 和 NSDateComponents 返回不同的周数值

ios - 从另一个类停止或播放 AVAudioPlayer - 应用程序崩溃 - Swift

ios - Swift 中的弹出 View

objective-c - MPMoviePlayerController mp4 文件流

ios - 永远不会调用 Xml 解析器函数

ios - 验证应用程序商店分发的代码签名的奇怪错误

objective-c - DEBUG宏在哪里定义的?

ios - 如何用 subview 隐藏 UITextField 文本?

ios - 将 BuddySDK 平台添加到包含 RestKit 的现有项目