zelnet94 / MovieViewer

A flicks based app to watch your favorite movies
1 stars 0 forks source link

Week 2 requirements complete. Review my app! #3

Open zelnet94 opened 8 years ago

zelnet94 commented 8 years ago

I am trying to fix my storyboard after it caused a big error on my project when I embedded the navigation controller within MoviesViewController. Please review my app! /cc @codepathreview

minhkhang1795 commented 8 years ago

It does not appear that you have added a Week 2 README to your current README. Just add it under your Week 1 README. Be sure to also include an animated gif in your README to show a demo of your finished app. When properly linked, the gif should render (animate) within your README file. Check the README template for syntax for displaying animated gif files.

Also, your week 2 project is not completed and we cannot grade your assignment without the requirements completed. I see that you have created the Detail Scene, but you linked the segue incorrectly. You should link a push segue from a MovieCell to Detail View Controller in your Story Board.

Furthermore, it looks like your MBProgressHUD will show and disappear instantly instead of waiting until the data is loaded from the network. You should put MBProgressHUD.hideHUDForView() inside the network request:

        MBProgressHUD.showHUDAddedTo(self.view, animated: true)
        let task: NSURLSessionDataTask = session.dataTaskWithRequest(request,
            completionHandler: { (dataOrNil, response, error) in
                MBProgressHUD.hideHUDForView(self.view, animated: true)
                if let data = dataOrNil {
                    if let responseDictionary = try! NSJSONSerialization.JSONObjectWithData(
                        data, options:[]) as? NSDictionary {
                            print("response: \(responseDictionary)")
                            self.movies = responseDictionary["results"] as? [NSDictionary]
                            self.tableView.reloadData()
                    }
                }
        })

I'll check back later once you complete your week 2 assignment. Best, Khang CodePath Grader

zelnet94 commented 8 years ago

The Week 2 requirements are complete, please review my app. /cc @codepathreview

minhkhang1795 commented 8 years ago

:+1: Nice work! The point of this homework was to get familiar with two common forms of navigation in iOS (push and tab bar). It also provided a chance to extend your Flicks app in new ways. Below is my specific feedback:

tableView.dataSource = self
tableView.delegate = self

Those 2 lines are only needed in viewDidLoad(). In sum, the correct code snippet of refreshControlAction() is shown below:

func refreshControlAction(refreshControl: UIRefreshControl) {
        // ... Create the NSURLRequest (myRequest) ...
        let apiKey = "a07e22bc18f5cb106bfe4cc1f83ad8ed"
        let url = NSURL(string: "https://api.themoviedb.org/3/movie/\(endpoint)?api_key=\(apiKey)")
        let request = NSURLRequest(
            URL: url!,
            cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData,
            timeoutInterval: 10)

        // Configure session so that completion handler is executed on main UI thread
        let session = NSURLSession(
            configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
            delegate: nil,
            delegateQueue: NSOperationQueue.mainQueue()
        )
        let task: NSURLSessionDataTask = session.dataTaskWithRequest(request,
            completionHandler: { (dataOrNil, response, error) in
                if let data = dataOrNil {
                    if let responseDictionary = try! NSJSONSerialization.JSONObjectWithData(
                        data, options:[]) as? NSDictionary {
                            print("response: \(responseDictionary)")

                            // Reload the tableView now that there is new data
                            self.movies = responseDictionary["results"] as? [NSDictionary]
                            self.tableView.reloadData()

                            // Tell the refreshControl to stop spinning
                            refreshControl.endRefreshing()
                    }
                }
        })
        task.resume()
    }

Then, in your viewDidLoad(), insert these 2 lines of code:

refreshControl.addTarget(self, action: "refreshControlAction:", forControlEvents: UIControlEvents.ValueChanged)
tableView.insertSubview(refreshControl, atIndex: 0)

The whole code snippet:

let refreshControl = UIRefreshControl()

 override func viewDidLoad() {
        super.viewDidLoad()
        ....
        refreshControl.addTarget(self, action: "refreshControlAction:", forControlEvents: UIControlEvents.ValueChanged)
        tableView.insertSubview(refreshControl, atIndex: 0)
}

You can look at full instruction here: Adding pull to refresh

let url = NSURL(string: "https://api.themoviedb.org/3/movie/\(endpoint)?api_key=\(apiKey)")

We have a detailed Project 2 Feedback Guide which covers the best practices for implementing this assignment. Read through the feedback guide point-by-point to determine ways you might be able to improve your submission. You should consider going back and implementing these improvements as well. Keep in mind that one of the most important parts of iOS development is learning the correct patterns and conventions.

If you have any particular questions about the assignment or the feedback, feel free to reply here or email us at universitysupport@codepath.com.

Best, Khang CodePath Grader