[英]Xcode 7 Err “Editor placeholder in source code”
我剛開始嘗試學習Swift,但是一個錯誤不斷出現,我不知道為什么 - “源代碼中的編輯器占位符”。 可能導致這種情況(由於我是新成員,我無法發布代碼圖片)。
謝謝
它剛剛發生在我身上,但是一旦我查看代碼,原因就非常簡單了。 我使用autofill類作為函數的參數。 麥角“占位符”
//Leaving the auto-completed signature gave the error
myclass.myFunction(myParam: UIControl)
//removing the auto complete params and using a real one cleared error
myclass.myFunction(myUIControl)
剛發生在我使用xcode 7.3.1的現有代碼“昨天很好”。 我沒有看到任何錯誤,所以我在上面的行上重新鍵入(有問題的行以查看它出錯的地方)並刪除了原始內容並且錯誤消失了。 git diff顯示沒有變化。
對我來說,它有助於解決這個問題(我的代碼是正確的)只是應用Xcode - 產品 - 清潔(Shift + Cmd + K)
它發生在我身上,但我忘了定義一部分代碼:
當我收到錯誤時:
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeTableViewCell",
forIndexPath: NSIndexPath) as! EmployeeTableViewCell
我修好后:
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeTableViewCell",
forIndexPath: indexPath) as! EmployeeTableViewCell
我有同樣的問題,它是由雙空格(Xcode 8.1 beta)引起的
之前:
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
之后(工作!):
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
(2個空格在“style:”之后)
我在做Udemy課程時遇到了這個問題,但沒有使用新的Swift 3信息更新課程。 至少我正在猜測的是這個問題導致了這個錯誤。
舊破代碼:
let cell = UITableViewCell(style: UITableViewCellStyle, reuseIdentifier: "Cell")
新的,有效的代碼
let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "Cell")
當我從Udacity.com開始練習初學練習時,我遇到了這個問題。 我之后發現的原因是因為Xcode會將變量的類型(如int或Bool)作為占位符,並且您必須自己將其替換為實際值。
func screenVIP(age: Int, onGuestList: Bool, knowsTheOwner: Bool) {
最后,您應該用給定的值替換它,如下所示:
screenVIP(age: age, onGuestList: onGuestList, knowsTheOwner: knowsTheOwner)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.