Core Data bizarre issue

Hi guys, hope you are all safe. I recently launched my 5th app, it’s called GlucoTrak for diabetics. It allows users to enter readings (besides linking them to many useful resources and videos) and I used Core Data tp persist the entries while I had a label that displayed when it was taken (I used Chris’ one minute you tube video on date timer). I checked the core data entries many times before launching and all the entries worked fine. Just today I saw that when I enter a new reading the time label gets updated to the latest entry time and date! For instance, I had an entry last week Tuesday 10 am. Today when I added a new entry at 8 am, the time for both became today’s date and time! It was fine before! Any idea why? Appreciate your help, thanks. (Actually anytime I launch the app all the date and time becomes current date and time!!)

Hi @Guru_N

With out examining the code, I would guess that the init method is running and setting the Date() rather than fetching the date object from the database.

I would step through the start-up code and see where it leads you.

Good luck.
Blessings,
—Mark

Thanks a lot Mark for your quick response, appreciate it. If I may, here’s what I did: I have 2 entities which are inputs from textfields in the AddViewController where user adds fasting, after meal etc, and second field where they enter the readings. In the main VC, I have 2 labels to display the user inputs, and a label for time and date so they can track. In the Tableview cell for row block I have let currentDate = Date()
let formatter = DateFormatter()
formatter.timeStyle = .short
formatter.dateStyle = .short
let dateTimeString = formatter.string(from: currentDate)
cell.dateTimeLbl.text = “(dateTimeString)”
This was working fine, but suddenly everything changes to current time as I mentioned. Apologies if I took up too much of your time, but if you could spot what’s wrong that’ll be great :pray:

Looks like you are just setting the label to Date() which will be today’s date as you are finding.

You need to fetch the date object from CoreData and set the label text to that.

I assume you are saving to Core Data after the user inputs data in the fields you describe?

Blessings
—Mark

Oh ok! I don’t have a date entity set so far (because it was working without so I thought it wasn’t needed). I’ll try again and post, thanks a lot Mark! Appreciate you taking the time.

Hi Mark, morning. I deleted the old code for date and time, created a new entity for time in core data, added a text field for user to enter date and coded the calendar date picker so user can simply select the date and time It works now, have re-submitted it. Thanks a lot for your help, appreciate it.

Well done.

Glad to hear you got it sorted out.

Happy coding!
Blessings,
—Mark

Hi Mark, how are you? In an inexplicable twist, App Store rejected my 3rd version update after approving the first two versions!
They cited reasons like Intellectual property which says app has to be from a medical company, and Minimum functionality and physical harm which they dropped after my first appeal.
In my second appeal I submitted just now I got approval from the sources I provide links top which App Store wanted. I re-emphasised the fact that this is not a medical app, and that I use Core Data, Datepicker, Tableview etc so not sure why they are saying minimum functionality.
Anything come to your mind? How did they approve first two versions and suddenly woke up now?!
Thanks

Hi,

When Apple says, “minimum functionality” they are looking from the user perspective, not the developer’s. In short, they want to see it do more.

For example, I used a free app for years that calculated the Golden Ratio of a rectangle in inches–I am a woodworker and the Golden Ratio is used a LOT in woodworking. The developer quit updating it, so it became unusable in the new iOS, and after taking Chris’ course, I decided I needed to step up.

I submitted my free version of similar functionality and sent it in. Got the same rejection you did. My solution was to add more results of the ratio–MM, CM, Inches (feet), and provide the choice of calculating the Silver and Bronze ratio (which is not used as much in woodworking) as an option.

This is all it took and Apple approved. This simple app happens to be my most popular app, with about 100 downloads a week. Who knew…

So I would look and see what other functionality you can provide the user and I am sure Apple will approve the next time.

Good luck.
Blessings,
—Mark

PS I forgot to add that the App Store review process is significantly influenced by the person who makes the call. Apple is trying to level the playing field, not sure how successful they are so for. They do have a new appeals process so that should help. Sometimes, just resubmitting gets it through.

Thank you for your time Mark and for a detailed explanation. I had this minimum functionality issue with my first app, and it was approved after I added map view, av foundation etc. I can always add more elements my issue here is they are suddenly saying it has to come from a company as they see it as a medical app, which it is not ( **Guideline 5.2.1 - Your app must be published under a seller name and company name that reflects a medical institution.) I appealed again and they’ve scheduled a call, will keep you posted, thanks again for all your help and patience, appreciate it.