title: Cannot subscript a value of type '[AnyObject]?' with an index of type 'UInt32'
body: <p>The goal of the code below is this - get all objects from the parse.com class called <code>OnlineUsers</code> and then find a RANDOM number between <code>0</code> and <code>results.count</code> and then use that object for something.</p>
  
  <p>Issue is that when I try to get the object at position <code>results[randomNumber]</code>, I get the error below. I get the same error if I try <code>results[randomNumberCast]</code> below.</p>
  
  <p>How can I solve this problem? </p>
  
  <pre><code>func findRandomOnlineUser() {
      if PFUser.currentUser() != nil {
          var user1 = PFUser.currentUser()
          var user2 = PFUser()
  
  
  
          //find user2, i.e. some user who is online right now
          //Showing OnlineUsers only
          let onlineUsersQuery = PFQuery(className: "OnlineUsers")
          onlineUsersQuery.findObjectsInBackgroundWithBlock({ (results:[AnyObject]?, error:NSError?) -&gt; Void in
  
              if results!.count &gt; 0 {
                  self.mLog.printToLog("launchChatwithRandomUser() -- There are more than zero objects in OnlineUsers")
  
                  //help: http://stackoverflow.com/questions/26770730/apple-swift-placing-a-variable-inside-arc4random-uniform
                  let randomNumber = arc4random_uniform(UInt32(results!.count))
                  var randomNumberCast = Int(randomNumber)
  
                  if let userObject = results[randomNumberCast] {
                      user2 = userObject["user"] as! PFUser
                  } else {
                      //handle the case of 'self.objects' being 'nil'
                  }
  
      } else {
          //TODO: Show a prompt that user is not logged in and then take user to Login Screen
      }
  
  
  }
  </code></pre>
  
  <p>Error Message:</p>
  
  <p><img src="https://i.stack.imgur.com/prnDt.png" alt="Screenshot showing the error message"></p>