title: 'The class PFUser must be registered with registerSubclass before using Parse.'
body: <p>I've looked around and all the other answers do not work for me, I'm trying to query PFUser, but I keep getting an exception of 'The class PFUser must be registered with registerSubclass before using Parse.'</p>
  
  <p>This is where the issue occurs:</p>
  
  <pre><code>override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -&gt; JSQMessageAvatarImageDataSource! {
      let message = messages[indexPath.item]
      if self.avatars[message.senderId] == nil {
          var imageView = JSQMessagesAvatarImage(placeholder: UIImage(named: "profile"))
          self.avatars[message.senderId] = imageView
  
          let user = users[message.senderId]!
          print(user)
          var parseAvatar = PFFile()
  
          PFUser.registerSubclass()
          let imageQuery = PFUser.query()
          imageQuery?.whereKey("objectId", equalTo: user.objectId!)
          imageQuery?.limit = 1
  
          imageQuery?.findObjectsInBackgroundWithBlock({ (images: [AnyObject]?, error: NSError?) -&gt; Void in
              if imageQuery?.countObjects() == 0 {
                  return
              } else {
                  for image in images! {
                      if image.objectForKey("profileImage") == nil {
                          return
                      } else {
                          let userPic = image.objectForKey("profileImage") as! PFFile
                          userPic.getDataInBackgroundWithBlock({ (imageData: NSData?, error: NSError?) -&gt; Void in
                              if (error == nil) {
                                  let image = UIImage(data: imageData!)
                                  imageView.avatarImage = JSQMessagesAvatarImageFactory.circularAvatarImage(UIImage(data: imageData!), withDiameter: 30)
                              }
                          })
                      }
  
                  }
              }
          })
  
              // Reload entire table now that the avatar is downloaded
              self.collectionView?.reloadData()
  
          }
  
      return self.avatars[message.senderId]
  }
  </code></pre>
  
  <p>Any idea what I might be missing here? I did this in another file, and it doesn't have that issue. So I'm a little confused.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Like this?</p>
  
  <pre><code>import Foundation
  import Parse
  
  class TradeUser : PFUser {
  
  override class func initialize() {
      self.registerSubclass()
  }
  
  var userID : String {
      get {return objectForKey("objectId") as! String}
      set { setObject(newValue, forKey: "objectId") }
  }
  
  var emailAddress : String {
      get {return objectForKey("email") as! String}
      set { setObject(newValue, forKey: "email") }
  }
  
  var firstName : String {
      get {return objectForKey("firstName") as! String}
      set {setObject(newValue, forKey: "firstName")}
  }
  
  var lastName : String {
      get {return objectForKey("lastName") as! String}
      set {setObject(newValue, forKey: "lastName")}
  }
  
  var primaryQueue : String {
      get {return objectForKey("primaryQueue") as! String}
      set {setObject(newValue, forKey: "primaryQueue")}
  }
  
  var image : PFFile {
      get { return self["profileImage"] as! PFFile }
      set { self["profileImage"] = newValue }
  }
  </code></pre>
  
  <p>}</p>