Using iOS 16 I am finding that the use of task.isInvalidated doesn't prevent a crash. In fact I get a warning in the editor that says that This property is defined on RLMEmbeddedObject, and may not be available in this context." Nothing I try seems to get around this bug. Any ideas what I could try? Everything else works as you have it.
Swift package target 'Realm' is linked as a static library by 'Projectname' and 'Realm', but cannot be built dynamically because there is a package product with the same name.
This short but powerful tutorial has been a life saver as I struggled with the delete event that crashed my prototype and it never dawned on me to list the tasks (data) using the invalidated check. This tutorial is awesome and I now subscribed to your channel. :)
I got this error whenever I try to delete a task, and the list contains more than one: "Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'" Do you know why? And on iOS 16 applying ".onAppear { ... }" to the List doesn't work, but the new statement ".scrollContentBackground(.hidden)" can help UPDATE: I added a "delete button" below every TaskRow and it works well, so the problem must be connected to the swipe action MY SOLUTION: I found a solution using ".onDelete" applied to forEach cycle instead of using ".swipeActions"
Another great swiftUI tutorial Steph. Quick, to the point and informative to the end, and a fully functional app at the end in around 42 minutes, amazing! One request I would like to make is in the source if you could add comments to highlight what the code is doing, this would really help when looking back at the code again.
I learned a lot from this, thank you very much, App works like a charm on ios 15 but have you tried running the app on ios 16 , as on ios 16 the error you showed us on last part is not bieng solved by isInvalidated statement, please look into it, and find us a fix.
You can omit this problem by not using .swipeActions on TaskRow in TaskView. 1. delete swipeActions in TaskView.View 2. Change TaskRow.View: - add 2 new properties : @EnvironmentObject var realmManager: RealmManager var forDelete: ObjectId? - to the HStack add: Image(systemName: "trash") .foregroundColor(.red) .onTapGesture { realmManager.deleteTask(withID: forDelete!) } - add to the preview : TaskRow(task: "Work", completed: true) .environmentObject(RealmManager()) 3. Now back to the TaskView.View and Your ForEach should looks like here : ForEach(realmManager.tasks, id: \.id) { task in if !task.isInvalidated { HStack { TaskRow(task: task.title, completed: task.completed, forDelete: task.id) .onTapGesture { realmManager.updateTask(withID: task.id, completed: !task.completed) }}}}
This is amazing and good explanation, we have made this in Swift, and wondering how easy it's to make in SwiftUI. Thanks for sharing valuable information
thank you so much for your really great tutorial! i was looking for a good realm tutorial for beginners, and this is one of the best out there! THANK YOU!
Hi Stepahnie I believe there is an issue that started with iOS 16. Seems like when the realmManager deletes the object from the DB, the taskRow is not getting destroyed, which results in the below error: *** Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.' terminating with uncaught exception of type NSException This is solved by using .onDelete with the ForEach block, but the Delete button is not customizable. Is there a way to get around the exception with SwipeActions, if not is there any way to customize the .onDelete block to show the trashcan symbol?
I get an error due to conflict abt Realm package. Then i saw "Package Changed in version 10.49.3: Instead of adding both, only add one package." on mongoDB documentation. Solution is: project navigator -> targets -> build phases -> link binary with libraries.-> delete "Realm". There should be only "RealmSwift"
I loved swift UI. I hate setting constrains on storyboards. I tried to jump on sweet UI as soon as it was possible and tried to use it in production, but I took a huge L by doing it. What I overlooked was swift UI was only for IOS 13 and bigger versions. I was developing library and no big company took my library that had 13.0 as minimum version... I was forced to rewrite lib on UIViews.
Great job! Anychance you can make one using Storyboard vs SwiftUI? I have most of it, just want observe changes that happened to the DB in the background
Great tutorial! isInvalidated really worked well if there are multiple objects but getting an error when there is only one object to delete. Is there a solution for that?
Hello! thanks for great swiftUI tutorial! I'n new in swift/swiftui, help me pls, how to delete row with an animation? My app crashed with "objects deleted bla bla..." thank you very much
Hi Sebastian! Unfortunately, this doesn't doesn't cover Sync & MongoDB, just the CRUD actions and saving the tasks locally. Maybe we'll create one in the future covering that! - Stephanie
As someone who has been learning from your team, can I email someone to do a tutorial to expand this video? I have been struggling with a concept in mobile design that relates to a to-do application that I cannot find instruction on. I think because the concept is too hard, many people shy away. Is there an email?
Hi Brandon! We just got your email at support@designcode.io. We'll try to create a tutorial on creating multiple lists of tasks that in the future! Thanks for your suggestion! - Stephanie
Год назад
thank you for your tutorial but your code ( also on github ) has a NSObject error. Please make sure commit your true code. Thanks anyway.
How do you run on simulator instead of preview? There is an error when it tries to run on simulator: SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type RealmManager found. A View.environmentObject(_:) for RealmManager may be missing as an ancestor of this view. It is the line where the ForEach starts in, specifically the realm.Manager.tasks
Hi JetShell, Make sure to add the @EnvironmentObject in each view (@EnvironmentObject var realmManager: RealmManager) and that you've added the environmentObject modifier (.environmentObject(realmManager)) to each instance of TasksView and AddTasksView in ContentView. You can head over to the Github repo to compare it with your code: github.com/stephdiep/ToDoApp - Stephanie
Hi thank you for the tutorial, I am having one issue though which is when I add the task nothing get’s added and it remains blank I was wondering what the issue might be
Hey, A small doubt. I am adding the task but it is not getting added in real time, only when i stop the preview and start again does the task appear. Could someone help me out with what the issue could be ?
Hi! Don't forget to call the getTasks() function every time you add, update or delete a task, so the tasks array is updated and them updated in real-time in your view. Also, make sure your tasks variable in the RealmManager is @Published! You can also take a look at the source code and compare it with your own: github.com/stephdiep/ToDoApp - Stephanie
@@DesignCodeTeam Hi I ran into the same problem, I checked with the source code and everything matches; however the view was not updated in real time whenever a new task is added, I'll have to either tap on another task to update its status or delete one to get the new tasks to show.
Over complicated, just use obervedresults so much easier. Also adding all of your functionality in side the realm manager is bad, bad, bad. What if you end up with 10 objects, that file will become huge.
Using iOS 16 I am finding that the use of task.isInvalidated doesn't prevent a crash. In fact I get a warning in the editor that says that
This property is defined on RLMEmbeddedObject, and may not be available in this context." Nothing I try seems to get around this bug. Any ideas what I could try? Everything else works as you have it.
Swift package target 'Realm' is linked as a static library by 'Projectname' and 'Realm', but cannot be built dynamically because there is a package product with the same name.
Girl you Rock!!!! Awesome. I learned more from you in 42 minutes than from watching many hours of other videos. Thank you. Now it makes sense!!!!!!
This short but powerful tutorial has been a life saver as I struggled with the delete event that crashed my prototype and it never dawned on me to list the tasks (data) using the invalidated check.
This tutorial is awesome and I now subscribed to your channel. :)
Glad it helped!
Hi Steph, this is a really great tutorial. It has really helped me to create my own Apps. Keep up the great work, you are a star!!!
I got this error whenever I try to delete a task, and the list contains more than one: "Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'"
Do you know why?
And on iOS 16 applying ".onAppear { ... }" to the List doesn't work, but the new statement ".scrollContentBackground(.hidden)" can help
UPDATE:
I added a "delete button" below every TaskRow and it works well, so the problem must be connected to the swipe action
MY SOLUTION:
I found a solution using ".onDelete" applied to forEach cycle instead of using ".swipeActions"
Can you send the code of your solution please
it would help me a lot
@@НиколайКитов-ф5н
struct TasksView: View {
@EnvironmentObject var realmManager: RealmManager
var body: some View {
VStack {
Text("My tasks")
.font(.title2).bold()
.padding(.horizontal)
.padding(.top)
.frame(maxWidth: .infinity, alignment: .leading)
if realmManager.tasks.count > 0 {
List {
ForEach(realmManager.tasks, id: \.id) { task in
if !task.isInvalidated && !task.isFrozen {
TaskRow(task: task.title, completed: task.completed)
.onTapGesture {
realmManager.updateTask(id: task.id, completed: !task.completed)
}
}
}
.onDelete { indexSet in
indexSet.forEach { index in
let taskTodelete = realmManager.tasks[index]
realmManager.deleteTask(id: taskTodelete.id)
}
}
.listRowSeparator(.hidden)
}
.scrollContentBackground(.hidden)
}
Spacer()
}
}
}
@@alessiopoggi547 a huge human thank you
from russia with love
@@alessiopoggi547 This is amazing! Thank you! :D
It really is a crash course. Speedy and useful. Thank you very much.
Another great swiftUI tutorial Steph. Quick, to the point and informative to the end, and a fully functional app at the end in around 42 minutes, amazing! One request I would like to make is in the source if you could add comments to highlight what the code is doing, this would really help when looking back at the code again.
Glad it was helpful! Sure, I'll add comments in the source code! Thanks for your feedback!
- Stephanie
I learned a lot from this, thank you very much, App works like a charm on ios 15 but have you tried running the app on ios 16 , as on ios 16 the error you showed us on last part is not bieng solved by isInvalidated statement, please look into it, and find us a fix.
Anybody can help us with this problem?
You can omit this problem by not using .swipeActions on TaskRow in TaskView.
1. delete swipeActions in TaskView.View
2. Change TaskRow.View:
- add 2 new properties :
@EnvironmentObject var realmManager: RealmManager
var forDelete: ObjectId?
- to the HStack add:
Image(systemName: "trash")
.foregroundColor(.red)
.onTapGesture {
realmManager.deleteTask(withID: forDelete!)
}
- add to the preview :
TaskRow(task: "Work", completed: true)
.environmentObject(RealmManager())
3. Now back to the TaskView.View and Your ForEach should looks like here :
ForEach(realmManager.tasks, id: \.id) { task in
if !task.isInvalidated {
HStack {
TaskRow(task: task.title, completed: task.completed, forDelete: task.id)
.onTapGesture {
realmManager.updateTask(withID: task.id, completed: !task.completed)
}}}}
This was my tutorial on Swift and I loved it!
Glad it helped you get started!
Awesome. this will be tomorrow's task.
Nice, good luck!
Wow! Thank you for this
You're so welcome!
This is amazing and good explanation, we have made this in Swift, and wondering how easy it's to make in SwiftUI. Thanks for sharing valuable information
You are most welcome
thank you so much for your really great tutorial! i was looking for a good realm tutorial for beginners, and this is one of the best out there! THANK YOU!
OMG...I was looking for the reason to crash the application after deleting the realm object for a month, thanks for the solution
Glad it helped! ❤️
Hi Stepahnie
I believe there is an issue that started with iOS 16. Seems like when the realmManager deletes the object from the DB, the taskRow is not getting destroyed, which results in the below error:
*** Terminating app due to uncaught exception 'RLMException', reason: 'Object has been deleted or invalidated.'
terminating with uncaught exception of type NSException
This is solved by using .onDelete with the ForEach block, but the Delete button is not customizable.
Is there a way to get around the exception with SwipeActions, if not is there any way to customize the .onDelete block to show the trashcan symbol?
It made me think about future, about learning SwiftUI
I get an error due to conflict abt Realm package.
Then i saw "Package Changed in version 10.49.3: Instead of adding both, only add one package." on mongoDB documentation.
Solution is:
project navigator -> targets -> build phases -> link binary with libraries.-> delete "Realm". There should be only "RealmSwift"
Fantastic, This tutorial is awesome and I now subscribed to your channel. :)
Great tutorial! thank you!
Great tutorial thank you
Can you please create video for realm with multi thread environment.👍
Hi can you make a video on Expension panels/accordian in Swift , Uikit
I loved swift UI. I hate setting constrains on storyboards. I tried to jump on sweet UI as soon as it was possible and tried to use it in production, but I took a huge L by doing it.
What I overlooked was swift UI was only for IOS 13 and bigger versions. I was developing library and no big company took my library that had 13.0 as minimum version... I was forced to rewrite lib on UIViews.
Great job! Anychance you can make one using Storyboard vs SwiftUI? I have most of it, just want observe changes that happened to the DB in the background
Great tutorial!
isInvalidated really worked well if there are multiple objects but getting an error when there is only one object to delete. Is there a solution for that?
how can I find more of your video, I love you, thanks a lot
It shows an error for me it says
Value of type 'Task" has no member 'completed'
it will be create if we see new version of this video using Actor-Isolated Realms
Hello!
thanks for great swiftUI tutorial!
I'n new in swift/swiftui, help me pls, how to delete row with an animation? My app crashed with "objects deleted bla bla..."
thank you very much
Superb tutorial, do we get to the Sync & MongoDB part though?
Hi Sebastian! Unfortunately, this doesn't doesn't cover Sync & MongoDB, just the CRUD actions and saving the tasks locally. Maybe we'll create one in the future covering that!
- Stephanie
Thank U So Much!
As someone who has been learning from your team, can I email someone to do a tutorial to expand this video? I have been struggling with a concept in mobile design that relates to a to-do application that I cannot find instruction on. I think because the concept is too hard, many people shy away. Is there an email?
Hi Brandon! We just got your email at support@designcode.io. We'll try to create a tutorial on creating multiple lists of tasks that in the future! Thanks for your suggestion!
- Stephanie
thank you for your tutorial but your code ( also on github ) has a NSObject error. Please make sure commit your true code. Thanks anyway.
amazing good job 👍
Thank you! Cheers!
Is the instance of Realm that is created a shared instance (singleton) or are new ones created? If not how does realm handle shared instances?
I had an existing project I wanted to download this realm package to but it is stuck on loading screen is there any help I can get?
stephdiep... Is she from VietNam?
UAU Thank you so much
can we convert it to swift data or core data ?
Thanks
Stephanie you R-O-C-K ! ❤️ 📱💻 ⌚️
I am still getting the error when deleting after adding the isInvalidated logic :(
@@victorbrigido4815 I'm here looking for the same answer!
How do you run on simulator instead of preview?
There is an error when it tries to run on simulator:
SwiftUI/EnvironmentObject.swift:70: Fatal error: No ObservableObject of type RealmManager found. A View.environmentObject(_:) for RealmManager may be missing as an ancestor of this view.
It is the line where the ForEach starts in, specifically the realm.Manager.tasks
Hi JetShell,
Make sure to add the @EnvironmentObject in each view (@EnvironmentObject var realmManager: RealmManager) and that you've added the environmentObject modifier (.environmentObject(realmManager)) to each instance of TasksView and AddTasksView in ContentView.
You can head over to the Github repo to compare it with your code: github.com/stephdiep/ToDoApp
- Stephanie
How did you paint the whole screen, it only paints safe area? Thanks :))
Hi, if the background color doesn't cover the entire screen, you can add the .edgesIgnoringSafeArea(.all) to cover the entire screen.
- Stephanie
@@DesignCodeTeam Thank you:)
Hi thank you for the tutorial, I am having one issue though which is when I add the task nothing get’s added and it remains blank I was wondering what the issue might be
don't forget about init() in Your RealmManager and check syntax twice! ;)
Hey, A small doubt. I am adding the task but it is not getting added in real time, only when i stop the preview and start again does the task appear. Could someone help me out with what the issue could be ?
Hi!
Don't forget to call the getTasks() function every time you add, update or delete a task, so the tasks array is updated and them updated in real-time in your view. Also, make sure your tasks variable in the RealmManager is @Published!
You can also take a look at the source code and compare it with your own: github.com/stephdiep/ToDoApp
- Stephanie
@@DesignCodeTeam Hi I ran into the same problem, I checked with the source code and everything matches; however the view was not updated in real time whenever a new task is added, I'll have to either tap on another task to update its status or delete one to get the new tasks to show.
@@peterzhang6659 Did you manage to resolve the error? I have the same problem
Are where the assets?
Hi! The source code can be found at github.com/stephdiep/ToDoApp
- Stephanie
@@DesignCodeTeam Thank you
Stephanie Diep ❤Rock on
owww ain't you sweet ❤️
to be honest, you speak very fast without clear explanations.... I do prefer hacking swift more. Sorry.
I noticed she does speak fast, and the typing is so fast on the screen that I'm struggling to keep up. Great tutorial though!
Hi, you are so beautiful woman 😍 do u have instagram?
😂😂
🤣🤣🤣
Do you also teach on Udemy?
Loving your tutorials thanks ❤️
Over complicated, just use obervedresults so much easier. Also adding all of your functionality in side the realm manager is bad, bad, bad. What if you end up with 10 objects, that file will become huge.