Strategy to quickly understand Lines of Codes

• I am struggling to simply understand some Swift line of codes sometimes.

• For e.g. Lines 3 to 13 of the attached files took me 4+ hours to understand, and I am still not clear on it.

• Whenever you read lines of code and try to understand what’s going? what’s your approach? what strategy do you use to understand it quickly please?


    override func viewWillAppear(animated: Bool) {
        let wondersAppdel:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
        let wondersContext:NSManagedObjectContext = wondersAppDel.managedObjectContext
        let wonderFetchRequest = NSFetchRequest(entityName:"Wonders")
        wonderFetchRequest.predicate = NSPredicate(format:"wonderShow = %@", true)
        let sortDescriptor = NSSortDescriptor(key: "wonderName", ascending: true)
        wonderFetchRequest.sortDescriptors = [sortDescriptor]
        do {
            if let wonderFetchedResults = try wondersContext.executeFetchRequest(wonderFetchRequest) as? [Wonders]{
                wonders = wonderFetchedResults
            } else {
                print("ELSE if let results = Try..FAILED")
        } catch {
          fatalError("There was an error fetching the list of groups!")

Powered by WPeMatico

You may also like...

Comments are closed.