hi have problem with the swift error "Swift Editor Placeholder In Source File" This is my code
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell
let brandImage: UIImage = UIImage(named: self.brands[indexPath.row].name)!
cell.brandImageView.image = brandImage
return cell
}
I found the same question many times on SO. But none of them gave the answer I was looking for.
You get the Placeholder in source file
when you have one of these (where it says "String" with a blue background) in your code.
A placeholder is for us programmers. It says "here should be a value of the type String". You can click on it and start typing, to simply replace it with for example a variable name. You can also press tab to automatically select the next placeholder. This is very useful when you are calling a function with multiple parameters (and therefore multiple placeholders).
A placeholder is actually just normal text (<#T##Strign#>), but XCode "translates" it to look like how it does.
In your case the error is on line three.
...withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell
As you can see <#T##IndexPath#>
is a placeholder as normal text as I mentioned earlier. You probably want this to be indexPath
Try cmd + shift + k to clean the project and run your code again. This fixed the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With