title: how to use swift function loadLeaderboardSetsWithCompletionHandler
body: <pre><code>GKLeaderboardSet.loadLeaderboardSetsWithCompletionHandler(_ completionHandler: (([GKLeaderboardSet]?,NSError?) -&gt; Void)?)
  </code></pre>
  
  <p>I'm trying to use this class function to retrieve the information of the leaderboard sets from Game Center.</p>
  
  <pre><code>            var leaderboardSetsRetrived = [""]
          GKLeaderboardSet.loadLeaderboardSetsWithCompletionHandler({ (leaderboardSets, error) -&gt; Void in
              leaderboardSetsRetrived = leaderboardSets
          })
  </code></pre>
  
  <p>This is what I tried to do, but xcode says </p>
  
  <blockquote>
    <p>"Cannot convert value of type '([String], _) -> Void' to expected argument type '(([GKLeaderboardSet]?, NSError?) -> Void)?"</p>
  </blockquote>
  
  <p>What should I put for the parameters?</p>
  
  <p>What Game Center Programming Guide told me to do:</p>
  
  <blockquote>
    <p>Before you can load the leaderboards contained within a set, you must load the set itself. Retrieve the list of leaderboard sets for your game from Game Center and display their titles. Use the loadLeaderboardSetsWithCompletionHandler: method to retrieve the leaderboard sets for your app. You can then load the leaderboards for a specific leaderboard set using the loadLeaderboardsWithCompletionHandler: method.</p>
  </blockquote>
  
  <pre><code>@available(iOS 7.0, *)
  public class GKLeaderboardSet : NSObject, NSCoding, NSSecureCoding {
  
      public var title: String { get } // Localized set title.
  
      public var groupIdentifier: String? { get } // set when leaderboardSets have been designated a game group; set when loadLeaderboardSetsWithCompletionHandler has been called for leaderboards that support game groups
      public var identifier: String? // leaderboard set.
  
      // Loads array with all sets for game
      // Possible reasons for error:
      // 1. Communications problem
      // 2. Unauthenticated player
      // 3. Set not present
      @available(iOS 7.0, *)
      public class func loadLeaderboardSetsWithCompletionHandler(completionHandler: (([GKLeaderboardSet]?, NSError?) -&gt; Void)?)
  
      // Loads array with all leaderboards for the leaderboardSet
      // Possible reasons for error:
      // 1. Communications problem
      // 2. Unauthenticated player
      @available(iOS 7.0, *)
      public func loadLeaderboardsWithCompletionHandler(completionHandler: (([GKLeaderboard]?, NSError?) -&gt; Void)?)
  }
  
  extension GKLeaderboardSet {
  
      // Asynchronously load the image. Error will be nil on success.
  
      public func loadImageWithCompletionHandler(completionHandler: ((UIImage?, NSError?) -&gt; Void)?)
  }
  </code></pre>
  
  <p>code from GKLeaderboardSet.h</p>
  
  <p>Now my code is working.</p>
  
  <pre><code>GKLeaderboardSet.loadLeaderboardSetsWithCompletionHandler({ (leaderboard, error) -&gt; Void in
              })
  </code></pre>
  
  <p>But the function isn't receiving any parameters for some reason. I can't save the <code>leaderboardSets</code> that's supposed to be retrieved to a variable that I created.  According to the GKLeaderboard Class Reference:</p>
  
  <blockquote>
    <p>Parameters:</p>
  </blockquote>
  
  <pre><code>completionHandler
  </code></pre>
  
  <blockquote>
    <p>A block that is called when the categories have been retrieved from the server.</p>
    
    <p>The block receives the following parameters:</p>
    
    <p><code>leaderboardSets</code><br>
    An array of <code>GKLeaderboardSet</code> objects that provides the leaderboard sets for your game. If an error occurred, this value may be non-nil. In this case, the array holds whatever data Game Kit was able to download before the error occurred.</p>
    
    <p><code>error</code><br>
    If an error occurred, this error object describes the error. If the operation completed successfully, the value is nil.</p>
  </blockquote>