@@1ongole1 Looks like it is a known bug in Xcode 12.4. Check this out and let me know if this doesn't solve the problem developer.apple.com/forums/thread/662240
@@1ongole1 Sorry Monish. I haven't hit this problem yet but it looks like it is a problem for everyone. One thing you could try (until it is fixed) is see if you can lower your iOS version to a level where that goes away. Not ideal I know. But it may get you by until Apple can fix. Sorry I can't be of more help. :( Apple should fix this ASAP.
This is quite mind opening video. Thanks for it. I am working with iCloud and Coredata. Whenever I create or delete data it works properly on IOS simulator. When I add data on ios app, it also adds on MacOS app as well. But once I delete row of List on either ios app or macos app, it deletes it on MacOS app but UI of MacOS remain unresponsive, another way of saying it freezes the macosapp. I debugged it on MacOS app, it works on main thread. I run into this useful video, I believe I should make fetching operation on background thread. But how? Because I do not want to create an object as you did on video. I just want to delete row and keep continue to use app as it is.
DevKit! Congratulations - that is awesome. Welcome to the world of iOS development. Lots more to come. Glad you enjoyed the channel. Best of luck on the new job. Let us know how you are doing and what subjects interest you most. All the best.
This is quite mind opening video. Thanks for it. I am working with iCloud and Coredata. Whenever I create or delete data it works properly on IOS simulator. When I add data on ios app, it also adds on MacOS app as well. But once I delete row of List on either ios app or macos app, it deletes it on MacOS app but UI of MacOS remain unresponsive, another way of saying it freezes the macosapp. I debugged it on MacOS app, it works on main thread. I run into this useful video, I believe I should make fetching operation on background thread. But how? Because I do not want to create an object as you did on video. I just want to delete row and keep continue to use app as it is.
Hi Eva. That is a tough one to solve. Sounds like you may have a refresh problem. If you know it is being deleted in CoreData, see if you can't get an event or notification from when that happens. Then you can update the UI. Good luck!
May I ask a few questions? In timeline 2:22, you didn't put your code in background thread, but your printStats() func printed "off main thread", I tried on my side, it is always on main thread. How to ensures my background Core Data updates are all performed on same single thread? And another one is could we use GCD on Core Data like `DispatchQueue.global().async {}`.
Great question Film Reporter. The reason we are on the background thread here is because my URLSession call put us there. URLSession often does work on the background thread. So if we dispatch back via protocol delegate, when I do to printStats, I am on the background thread at that point. Thats all. Thanks for asking!
@@swiftarcade7632 Thanks for replying me. I get your point, but since the call of CoreData is inside URL session request closure, does that mean it is always in background thread? Then we don't need to put it in background thread in `createCoreDataWeatjer`again.
@@ZhouHaibo I see what you are saying now. Yes - I think you are right. The reason why it is good however, to still put the CoreData work on a background task is because you never know where that func is going to be called from. i.e it could be called from a main UI thread function. In which case to be safe you'd want to put it on a background thread. So yes. I believe you are right. Still good to call on background however in case you are invoking it from main thread. Great question!
@@swiftarcade7632 Thank you, I get that. May I know how to transition NSManagedObject instances between background thread and main thread. Let's say in your example, you may fetch the weather in viewDidLoad in background thread and when you add a new weather, you update it in main thread. But how to transition that data between background thread and main thread. I think your video doesn't show off it.
@@ZhouHaibo Checkout explanation at 3:35. We basically ask our persistentContainer for its view context (main thread), and the call context.perform (which will do work on main thread because that is where the view context came).
Great stuff! I got an issue though. I'm saving all my core data on a backgroundContext. On my SwiftUI view I'm using a @FetchRequest for my core data but this does not reflect changes I do on the backgroundContext. If I save using viewContext my view updates as well. How can I fix this? Thanks!
So as far as I, everything should work the same way between UIKIt and SwiftUI and @FetechRequest. My advice would be to create a simple standalone app, get it working there, and then app it to the real thing. Good luck!
@@swiftarcade7632 Thanks for the quick reply! I think I figured it out. This seemed to do the trick: viewContext.automaticallyMergesChangesFromParent = true
Got any other questions about Core Data? Let me know below.
I am getting this crash "CoreData _PFObjectIDFastHash64" only in iOS 14. Can you help me to resolve this issue.
@@1ongole1 Looks like it is a known bug in Xcode 12.4. Check this out and let me know if this doesn't solve the problem developer.apple.com/forums/thread/662240
@@swiftarcade7632 I gone through this thread and tried all the possible solution in that thread. But no luck ...
@@1ongole1 Sorry Monish. I haven't hit this problem yet but it looks like it is a problem for everyone. One thing you could try (until it is fixed) is see if you can lower your iOS version to a level where that goes away. Not ideal I know. But it may get you by until Apple can fix. Sorry I can't be of more help. :( Apple should fix this ASAP.
This is quite mind opening video. Thanks for it. I am working with iCloud and Coredata. Whenever I create or delete data it works properly on IOS simulator. When I add data on ios app, it also adds on MacOS app as well. But once I delete row of List on either ios app or macos app, it deletes it on MacOS app but UI of MacOS remain unresponsive, another way of saying it freezes the macosapp. I debugged it on MacOS app, it works on main thread. I run into this useful video, I believe I should make fetching operation on background thread. But how? Because I do not want to create an object as you did on video. I just want to delete row and keep continue to use app as it is.
Greetings from Russia. Really appreciate your work. Especially when i got my first job as jr ios dev your channel helps me a lot
DevKit! Congratulations - that is awesome. Welcome to the world of iOS development. Lots more to come. Glad you enjoyed the channel. Best of luck on the new job. Let us know how you are doing and what subjects interest you most. All the best.
@@swiftarcade7632 Yeah, sure. Thank you!
John is amazing! I love the way you explain things!
The video is awesome, thanks for share your knowledge!
Amazing....fantastic way of explanation 👍
Hi Ady. Welcome and thanks for the comment!
This is what I was looking for
Awesome!
This was really useful, thank you so much 😎
Very welcome. Glad you enjoyed it!
This was really helpful. Thank you so much. 😊😊😊😊😊🤗🤗🤗
Very welcome Ashish.
thank you very much!
This was really useful, Thank you so much ❤️
Most welcome Ankit. Thanks so much for stopping by.
Thanks you
Very good, thank you so much!
Most welcome Tiv. All the best!
This is quite mind opening video. Thanks for it. I am working with iCloud and Coredata. Whenever I create or delete data it works properly on IOS simulator. When I add data on ios app, it also adds on MacOS app as well. But once I delete row of List on either ios app or macos app, it deletes it on MacOS app but UI of MacOS remain unresponsive, another way of saying it freezes the macosapp. I debugged it on MacOS app, it works on main thread. I run into this useful video, I believe I should make fetching operation on background thread. But how? Because I do not want to create an object as you did on video. I just want to delete row and keep continue to use app as it is.
Hi Eva. That is a tough one to solve. Sounds like you may have a refresh problem. If you know it is being deleted in CoreData, see if you can't get an event or notification from when that happens. Then you can update the UI. Good luck!
You are amazing
This helps, thanks
No problem!
May I ask a few questions? In timeline 2:22, you didn't put your code in background thread, but your printStats() func printed "off main thread", I tried on my side, it is always on main thread. How to ensures my background Core Data updates are all performed on same single thread? And another one is could we use GCD on Core Data like `DispatchQueue.global().async {}`.
Great question Film Reporter. The reason we are on the background thread here is because my URLSession call put us there. URLSession often does work on the background thread. So if we dispatch back via protocol delegate, when I do to printStats, I am on the background thread at that point. Thats all. Thanks for asking!
@@swiftarcade7632 Thanks for replying me. I get your point, but since the call of CoreData is inside URL session request closure, does that mean it is always in background thread? Then we don't need to put it in background thread in `createCoreDataWeatjer`again.
@@ZhouHaibo I see what you are saying now. Yes - I think you are right. The reason why it is good however, to still put the CoreData work on a background task is because you never know where that func is going to be called from. i.e it could be called from a main UI thread function. In which case to be safe you'd want to put it on a background thread. So yes. I believe you are right. Still good to call on background however in case you are invoking it from main thread. Great question!
@@swiftarcade7632 Thank you, I get that. May I know how to transition NSManagedObject instances between background thread and main thread. Let's say in your example, you may fetch the weather in viewDidLoad in background thread and when you add a new weather, you update it in main thread. But how to transition that data between background thread and main thread. I think your video doesn't show off it.
@@ZhouHaibo Checkout explanation at 3:35. We basically ask our persistentContainer for its view context (main thread), and the call context.perform (which will do work on main thread because that is where the view context came).
Great stuff! I got an issue though. I'm saving all my core data on a backgroundContext. On my SwiftUI view I'm using a @FetchRequest for my core data but this does not reflect changes I do on the backgroundContext. If I save using viewContext my view updates as well. How can I fix this? Thanks!
So as far as I, everything should work the same way between UIKIt and SwiftUI and @FetechRequest. My advice would be to create a simple standalone app, get it working there, and then app it to the real thing. Good luck!
@@swiftarcade7632 Thanks for the quick reply! I think I figured it out. This seemed to do the trick: viewContext.automaticallyMergesChangesFromParent = true
Awesome 👍🏻
Thanks Rohan.
Why haven't you used background context?
Hi Roman. Thank you for the question. Do you mean private queue? We could definitely do it that way too. Cheers.