0
に拡張内のプロパティにアクセスすることはできません。どうすればそれにアクセスできますか?は、私はクラスの内部でそれにアクセスしようとする場合、私は<code>Use of unresolved identifier 'selectedCategory'</code>を取得し、同じクラス</p> <p>の延長で宣言されたプロパティ<code>let selectedCategory</code>にアクセスすることはできませんスウィフト2.1
extension CreateRecipeVC: RecipeCategoryTableVCDelegate {
func categoryController(controller: RecipeCategoryTableVC, didSelectCategory category: String) {
let selectedCategory = category
self.navigationController?.popViewControllerAnimated(true)
let cell = RecipeCategoryCell()
cell.configureSelectedCategoryCell(selectedCategory)
}
}
class CreateRecipeVC: UIViewController, ... {
if selectedCategory != nil {
...
}
}
** 'categoriesController(didSelectCategory:)'の中の 'selectedCategory'は変数**ではありませんか? – Eendje
実際には...機能の外に移動すると、「拡張機能には格納されたプロパティが含まれていない可能性があります。」というエラーが表示されます –
これはすでに答えです:拡張機能でプロパティを設定することはできません。サブクラス化する必要があります。 – TPlet