Whenever I do Core Data, the Laws of Core Data by
@davedelong is always my northern star

Below are some of take aways from that post

davedelong.com/blog/2018/05/0…
1) Core Data is more than just SQLite wrapper, it manages objects, relationships, fetching, faulting, ...
2) Having 2 context: 1 main and 1 background that are both backed by the persistent coordinator. In modern Core Data stack, NSPersistentContainer has default viewContext already, we just need another newBackgroundContext
3) Never use a fetched NSManagedObject outside its context's queue.
4) The viewContext is for fetching NSManagedObject on the main queue, and those objects are meant for read only. All mutating operation should be in the background context.
5) Better, like I usually do, is to treat CoreData as a cache, and use plain old struct for UI. This reduces dealing with faulting and optional
6) Using struct that mirrors Core Data NSManagedObject, it looks verbose (you can use code generator or Sourcery for this) but it's safer

onmyway133.com/blog/how-to-us…
7) A nice trick to quickly convert struct to NSManagedObject is to use reflection with Mirror. NSManagedObject subclasses from NSObject so it is key value compliant

onmyway133.com/blog/how-to-co… Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Khoa 🔥

Khoa 🔥 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @onmyway133

22 Nov 20
How to gain product ideas?

1) Scratch your own itch. If you don't have any itch to scratch, stop here. This is awkward. Go travelling. Go exploring the world. The world always has problems and needs solution. Image
2) Build any service, app or website. Along the way you'll find tons of things you need that and unsolved by existing solutions, and tons of things you can improve upon.
3) Sign up for some paid newsletters to find ideas. This is the worst. This is like someone browsing through a tatoo catalog. You're doing things for trend, for money, not for your self drive 👎
Read 9 tweets
19 Nov 20
New program reduces App Store commission to 15 percent for small businesses earning up to $1 million per year

apple.com/newsroom/2020/…
1) "earning up to $1 million" means proceeds, not sales. This is what we get after Apple's cut. "up to" means $999.999
2) "if they earned up to $1 million in proceeds during the previous calendar year". This means that if $1M is surpassed, the standard rate (30%) kicks in for the rest of the year, and also next year.
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!