Giter Site home page Giter Site logo

ac3.2-coredataarticles's Introduction

Core Data Articles

The master branch has a working project that (at the moment) is pulling in all the opinion articles.

NB: As of now it does not do uniquing so multiple runs of the app will double up records. I'll get back to you on this one. (Pulling hair out.)

Fun stuff for KIDS (to keep them out of trouble)

  1. Complete the Article object in the data modeler without including any nested structures. I.e. no "*_facet" fields and no "multimedia". We'll do that next time.

  2. Add a Search bar to the TableView and implement its delegate methods to accept input from it. Search Bar Delegate.

  3. Alter the initializeFetchedResultsController function so that it can be re-reun with new parameters. You want to pass in a predicate and a sort. This will be done via the search bar input from the user. Ooh input from the user is bad. This hearkens back to the pre Battleship era where we processed input from the user on the command line. You should:

    1. Get the string from the search bar.

    2. Parse out a predicate string and a sort, probably using components(separatedBy: String). E.g. user

      p=abstract/environment s=title
      

      After plucking out "abstract", "environment" and "title" you can update these lines accordingly:

      let sort = NSSortDescriptor(key: "title", ascending: true)
      .
      .
      .
      
      // current line
      // let predicate = NSPredicate(format: "title < %@", "M")
      
      let predicate = NSPredicate(format: "@K contains[c] %@", field, search)
      
      

      Note, in this example for the predicate I'm making both the field and its value controllable by the user. It might be easier to start with just the value and then add the field.

      let predicate = NSPredicate(format: "abstract contains[c] %@", search)
  4. Add sections as per the sectionNameKeyPath parameter of:

NSFetchedResultsController(fetchRequest: request, managedObjectContext: moc, sectionNameKeyPath: nil, cacheName: nil)

If you're feeling ambitious, you can also accept input from the user for this sectonNameKeyPath, either as another part of the search bar input or from more elaborate input (e.g. a settings VC with a picker).

ac3.2-coredataarticles's People

Contributors

jgresh avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.