行からカラム値を取得
Data Storeテーブルの行内の特定のカラム値を取得できます。つまり、行内の「Employee ID」カラムの値のみが必要な場合、この操作を使用して取得できます。
この操作は、以下に示す3つの方法で実行できます。
以下のすべてのコードセクションで使用されている<ROW_INSTANCE>は、行インスタンスページで定義されたインスタンスです。
カラムのデータ型がわかっている場合:
copy
let data : <T> = try <ROW_INSTANCE>.getValue(forKey: "<columnName>")
パラメータ:
- T: 期待される値のデータ型
- columnName: 取得するカラムの名前
サンプルコードスニペットは以下の通りです:
copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845) {( result ) in
//これをあなたのテーブルIDに置き換えてください and ROWID
switch result{
case .success ( let row) :
do{
let data : String = try row.getValue(forKey: "EmpID") as! String
print(data)
}
catch{
print("Error occured")
}
case .error( let error ) :
print( "Error occurred >>> \( error )" )
}
}
カラムのデータ型がわからない場合:
copy
let data : <T>? = <ROW_INSTANCE>.getValue(forKey: "<columnName>")
パラメータ:
- T: 期待される値のデータ型
- columnName: 取得するカラムの名前
サンプルコードスニペットは以下の通りです:
copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845) {( result ) in
//これをあなたのテーブルIDに置き換えてください and Row ID
switch result{
case .success ( let row) :
let data :String? = row.getValue(forKey: "EmpID")
print(data)
case .error( let error ) :
print( "Error occurred >>> \( error )" )
}
}
getValue()を使用しない場合:
copy
let data : <T>? = <ROW_INSTANCE>[ "<columnName>" ]
パラメータ:
- T: 期待される値のデータ型
- columnName: 取得するカラムの名前
copy
ZCatalystApp.shared.getDataStoreInstance().getTableInstance(id: 1096000000002071).getRow(id: 1096000000002845) {( result ) in
//これをあなたのテーブルIDに置き換えてください and Row ID
switch result{
case .success ( let row) :
let data :String? = row[ "EmpID" ]
print(data)
case .error( let error ) :
print( "Error occurred >>> \( error )" )
}
}
最終更新日 2026-03-24 17:38:39 +0530 IST
Yes
No
Send your feedback to us
Skip
Submit