オーナーユーザーの取得
グループのオーナーは getOwnerWith(_:)
メソッドで取得できます。
返却される KiiUser
のインスンタンスは ID
のみを保持した不完全なインスタンスであることに注意してください。必要に応じて refresh(_:)
メソッドを実行して Kii Cloud よりユーザーの最新情報を取得してください。
なお、取得するユーザーとログイン中のユーザーが異なる場合、取得できる情報に制限があります。詳細は ユーザー属性 を参照してください。
グループのオーナーを取得するサンプルコードを以下に示します。
Swift:
-
do{ // Get the owner user of the group. let owner = try group.getOwnerSynchronous() // Refresh the owner to retrieve the latest data from Kii Cloud. try owner.refreshSynchronous() // Do something. } catch let error as NSError { // Handle the error. return }
-
// Get the owner user of the group. group.getOwnerWith() { (group, owner, error) -> Void in if error != nil { // Handle the error. return } // Refresh the owner to retrieve the latest data from Kii Cloud. owner?.refresh { (user, error) -> Void in if (error != nil) { // Handle the error. return; } // Do something. } }
Objective-C:
-
NSError *error; // Get the owner user of the group. KiiUser *owner = [group getOwnerSynchronous:&error]; if (error != nil) { // Handle the error. return; } // Refresh the owner to retrieve the latest data from Kii Cloud. [owner refreshSynchronous:&error]; if (error != nil) { // Handle the error. return; } // Do something.
-
// Get the owner user of the group. [group getOwnerWithBlock:^(KiiGroup *group, KiiUser *owner, NSError *error) { if (error != nil) { // Handle the error. return; } [owner refreshWithBlock:^(KiiUser *user, NSError *error) { if (error != nil) { // Handle the error. return; } // Do something. }]; }];