virat virat - 4 months ago 17
Swift Question

How to import objective c header file in swift project

enter image description here

I am trying to use SDWebImage in a Swift project. I dragged and dropped the SDWebImage library folder into my Swift project and created a bridging header by name listingApp-Bridging-Header.h

Then I imported the header file into my Swift file; like so imported

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

}


It's giving me an error saying
add ; before +
How would I import the file above into my Swift project correctly?

Answer

You need to quote the header file name when importing it in the bridging header. Like this:

#import "UIImageView+WebCache.h";

This is exactly the same syntax as importing header files in objc.