getter

    2熱度

    2回答

    我知道如何將存儲的財產的'setter'設置爲私有(例如public private(set) var name: String = "John"),但我們如何將計算的財產的'setter'設置爲private?在這種情況下,變量'age'的'setter'。當我試圖在set(newAge){}前面放置一個關鍵字時,XCode顯示錯誤。那麼是否有可能將計算屬性的'setter'設置爲private

    2熱度

    1回答

    如何解決此錯誤? Variable with getter/setter cannot have an initial value 這裏是我的代碼: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { var cell: UITa

    0熱度

    2回答

    下面是一個迭代整個數組的getter示例,預計將返回一個a爲true的元素。但test.active返回undefined。 var test = { arr: [ {id: 1, a: false}, {id: 2, a: false}, {id: 3, a: true}, {id: 4, a: false}, {id: 5, a: f

    0熱度

    2回答

    我不確定如何爲使用字符串哈希集的類文件創建getter和setter方法。我是否正確地表示,因爲沒有使用hashset進行索引,getter方法會返回整個集合,並且setter只會將元素添加到集合中? import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class Names {

    0熱度

    1回答

    修復了所有其他問題。目前試圖在函數fightCrime中從currentPowerLevel中扣除10%。但是,如果沒有本地變量,我必須處理用戶輸入的數字,並從中扣除10%。問題是通常我會有一個局部變量和一個設置的數字,我可以簡單地重新訪問並減去數字乘以.1。 package superherodriver; /** * * @author Daniel */ public class

    0熱度

    3回答

    好的,所以我有一個arraylist在我的main中聲明,因爲在其他地方它引發了一個錯誤。不過,我想在以後專門使用該數組列表來獲得一個getter,但它不能識別數組列表,因爲它在我的主數據庫中。 的錯誤是 「它不能被解析爲一個變量」 。 我該怎麼做才能糾正這個問題? public static void main(String[] args) { ArrayList <String> S

    -1熱度

    1回答

    我需要將我的連接發送到CarDAO類。我爲此創建了getMyConn getter,但它會輸入「myConn無法解析爲變量」。我怎麼能爲此創建getter? public class ConnectionDB { public ConnectionDB() { String dbHost="localhost"; String dbDatabase="cars"

    0熱度

    1回答

    好吧,所以我有一個驅動程序類和一個數組列表(正如你可能猜到的那樣)。 我的arraylist充滿字符串,我通過我在其他課程中創建的getter訪問它。 它表示「應該以靜態方式訪問類型爲Desktop的靜態方法getMouseList()」。我應該如何解決這個問題?你有沒有看到其他的錯誤? 感謝大家誰可以幫忙! 因此,這裏是我的代碼: 類: static ArrayList <String> Str

    20熱度

    1回答

    超類: class MySuperView : UIView{ var aProperty ; } 子類繼承父類: class Subclass : MySuperClass{ // I want to override the aProperty's setter/getter method } 我要重寫父類的屬性的setter/getter方法, 如何在Swif

    0熱度

    2回答

    我是PHP的新手,所以現在我需要驗證模型與靜態變量。 這是我 class Setting extends Model { protected $table = 'settings'; public static $rules = [ 'skey' => 'required|unique:table,id,' . Route::input('settings')