             postsQuery.whereKey("user", equalTo: PFUser.currentUser()!)
             postsQuery.findObjectsInBackgroundWithBlock {(objects:[PFObject]?, error: NSError?) -> Void in
                 self.posts = objects as? [Post] ?? []
+                self.index = self.posts.count - 1
+                
                 for post in self.posts {
                     print(post)
                 }

    
    func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
        print("previous")
        let vc = UIViewController()
        let view = UIView(frame: CGRectMake(100,100,100,100))
        view.backgroundColor = UIColor.blueColor()
        vc.view = view
        return vc
    }
    
    func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
        print("next")
        let vc = UIViewController()
        let view = UIView(frame: CGRectMake(100,100,100,100))
        view.backgroundColor = UIColor.redColor()
        vc.view = view
        return vc
    }

}

class MainPageViewController: UIPageViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate, UIPageViewControllerDelegate, UIPageViewControllerDataSource {
    
    var posts: [Post]!
    var index: Int!
    
    override func viewDidLoad() {
        super.viewDidLoad()
