源文件中的Swift Editor占位符 [英] Swift Editor Placeholder in source file
问题描述
嗨有快速错误源文件中的Swift编辑器占位符的问题
这是我的代码
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
}
推荐答案
我在SO上多次发现同样的问题。但他们都没有给出我想要的答案。
I found the same question many times on SO. But none of them gave the answer I was looking for.
当你有源文件时,你得到占位符其中一个(代码中带有蓝色背景的String)。
You get the Placeholder in source file
when you have one of these (where it says "String" with a blue background) in your code.
占位符适用于我们的程序员。它说这里应该是String类型的值。您可以单击它并开始键入,只需将其替换为例如变量名称即可。您也可以按Tab键自动选择下一个占位符。当您调用具有多个参数的函数(因此多个占位符)时,这非常有用。
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).
占位符实际上只是普通文本(<#T ## Strign #>),但是XCode翻译它看起来就像它一样。
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
正如您所见< #T ## IndexPath#>
是一个占位符,就像我前面提到的普通文本一样。您可能希望这是 indexPath
As you can see <#T##IndexPath#>
is a placeholder as normal text as I mentioned earlier. You probably want this to be indexPath
这篇关于源文件中的Swift Editor占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!