Core Data malfunctioning - objective-c

This is a strange problem im getting every now and then.
Im parsing a JSON and storing it into CoreData using several Entities. I save the data from the JSON and then I pull it to show it on a screen.
The app works perfectly fine when it's launched from XCode, always. But when I open it any other time from the iPhone it sometimes, it only happens roughly once every 20 times, it doesnt show the data saved from the JSON, I beleive the problem is that the info saved in CoreData is corrupted some how, the dates specifically, sometimes I can get to see that the dates are null on screen.
Here's how I save the dates
[event setValue:[df dateFromString:(NSString *)[key objectForKey:#"startSaleDate"]] forKey:#"dateStartSale"];
[event setValue:[df dateFromString:(NSString *)[key objectForKey:#"finishSaleDate"]] forKey:#"dateEndSale"];
If I relauch the app, that is killing the app and launching it again, it all works perfectly again.
The JSON is always correct, apparently it does the funky thing after some hours being installed in the phone. Does that make sense?
Thanks.
[UPDATE]
I did some more testing. This is a difficult bug to catch because it only happens after several hours in the background.
Figure out that the only problem is actually storing NSDates. Not the rest of data. After some time in the background it fails to save the NSDate, even though the JSON has a valid Date it stores null. And everytime I refresh it keeps on storing null.
If I kill and launch the app it stores correctly the date.
I tried using models but it happens the same thing.
Any ideas? Im quite lost now.

I had such an issue once I believe. In my case it had something to do with the display mechanism.
--> Try reloading your data more frequently (or resetting your fetched results controller) to test this.

Sorry guys, It was all a silly mistake from my part.
I thought it was something related to the background because I wasnt able to reproduce it, and since it only happened every now and then.
Well the thing is that I if you went through the screens in a certain way a following a certain order a NSDateFormatter got badly initialised and that made that the dates weren't saved properly.
SO nothing to do with CoreData...

Related

saveEventually in Parse SDK sometimes saving only on app reload

I am using saveEventually in Parse iOS SDK instead of SaveInBackground, just in case there is no network available. Most of the time the save happens immediately. However, sometimes (presumably if there's a bad network connection) I'm having multiple items just getting stuck and nothing is being saved even though some time has passed and a network has clearly been available. The only way to push up all stored items and save them is by closing the app completely and then reopening it, and usually this will immediately save all!
I have found this mentioned from Parse:
"Objects saved with saveEventually will be stored locally in an on-disk
cache until they can be saved. They will be sent
immediately if possible. Otherwise, they will be sent the next time a
network connection is available."
That is clearly not the case in my experience.
I am wondering why the SDK is not realizing the network is available and if I can do anything to force it to try more often. I am also wondering how many times SaveInBackground would try to find a network and save, as I believe it will try a few times at least and if so I could possibly switch to trying that method.
Any ideas?

Retrieve lost data from my jawbone up3

I accidentally deleted my Jawbone UP app, I had 2, one being old from my Up24 and I recently realized it was only taking up space as an unused app but I accidentally deleted the new app I currently use for my up3.
Only different when it shows app icons for deleting is color.
I obviously now regret not making sure of the color to my new UP app. But too late for hindsight to help.
When I re-downloaded it, all my data from the past year is gone. It oddly kept the past 8 days which maybe is a default for all I know to only save the current week? Otherwise this makes no sense.I have tried everything in my phone and SD card. Nothing has an available cache from why I can see.
Then I went on jawbone.com to look up my data as I was told they backed it up there...
I did not know this before. But I went on and shows me the list, I forget what it's called but it has all year blank but has the last 8 days filled like it's all the data ever saved. I didn't delete anything from actual jawbone, only the stupid app and quickly reinstalled it. Only to find out all my 11 months of data, experience, goals, progress etc all gone. And now the UP app is treating me like a new "UPster" and I'm not. It doesn't seem to even know anything from smart coaches previous tasks and helpful suggestions based on me. Now it's all gone. I didn't write this down because I thought that's why may this app was for.
In the age of everything cloud storage it's appalling to see this has no such thing or backup that I see at all. Likely I lost all but hoping theirs a trick or a website or something I'm not aware of and could help. I also know some information in a phone even if deleted isn't actually deleted and I have been able to retrieve others deleted like they had a background copy of the data. This however does not seem to be the same. No matter what I do or where I go it seems that I have lost all data history.
I now have no desire or need for this useless bracelet if it won't even do the one thing I need it to, collect data and build progress with smart coach getting to know me. If the data is gone the point to all I was using the tracker for is now also gone. How is it not online where it says it should be? I'm assuming my app deletion also deleted any backups I may have had. And that's where I'm lost isn't that what backups like that are for? It now only shows me a week behind. The rest is gone. I don't know but I would imagine I could retrieve data lost. Otherwise why collect data. I was looking in my cloud drives but nothing is there. I just want what I lost, back.
Does it delete all cached items?
And why?
I should have my own account and I should be able to access it and look at and or retrieve my past information. Anyway I can I just need to know if possible and if so how do I get the data back? Or even manually input it because I have all my old weekly reviews on my Google account but they don't seem to be anything other than an email I can only look at. It won't sync or share info and without it being on the up app it does no good because I have no smart coach, nothing to relate new days to old ones with. Nothing. It doesn't even work with smart coach and that seems quite odd.
I had an account since day 1 and it is the same account I tried taking data files out of. I messaged Jawbone but it says 3 days before I get a reply. I'm feeling like Ill just need to give up but I've been sick for several years and this had literally been a lifeline to better health, motivation I've lost and need, support since I have no trainer to keep me focused or mindset...I got this to help while I have been Ill. This just posses me off real bad. not having all my old data. This seems ridiculous.
I'm sorry you're having these issues. In general, Jawbone does not delete any historical data unless you specifically request data/account deletion. Deleting the app from your phone should not remove data from the Jawbone servers unless that data had never been synced, which seems unlikely since you have the 8 most recent days.
One thing you should double-check is to make sure you're logging in with exactly the same email address that you had been using.
All this being said, contacting Jawbone customer support is the best way to solve your problem. If you haven't already, please reach out via the contact form:
https://help.jawbone.com/contact
The Jawbone tag on Stack Overflow is for programming questions related to the Jawbone UP API.

Intermittent errors with new code release to existing Mojolicious app

I'm having a problem with an existing Mojolicous app. I have added some new routes, views, controllers, and models, and am returning database results to view using Rose::DB::Object ORM.
I updated the production version today with code that had been working great on Morbo. But, on apache2/plack/psgi mod_perl config the new Models are only returning the queries about 1 in 5 sometimes 1 in 10 times.
I've eliminated a number of variables, like I can query the database directly and get my results no problem. Older Model's and their queries always work.
It appears that only this new functionality is intermittent. I have narrowed requests to only one server and have restarted apache. But, am now at the point that I don't understand why the issue is persisting.
I think this is some kind of mod_perl wonky behavior, but don't know why an apache restart doesn't fix it.
Any help or ideas would be awesome.
I did finally resolve this and it turned out to be something simple. I was missing the use statement for my controller in my main application script. The script where I setup the routes. I'm not sure I understand why it was working intermittently in production and working all the time in development. But, once I added:
use TheApp::Controller::Tags; in the main app pm it worked consistently.
In retrospect it feels like I should have figured it out sooner, but the fact that it worked part of the time led me down the wrong path. Hopefully this will help someone else sometime.

rufus scheduler exception

This is driving me a bit nuts, I have rufus doing some scheduling to call a rules engine (ruleby). So most work I have running is inside the running engine and then inside the scheduler. As a result when I have a error the information is a bit limited.
Fast forward, Im still working on my code but now I have this exception error:
'undefined method `+' for nil:NilClass'
It wasnt happening before, Im not sure exactly when it started and if it was what I was doing with the code or some events that came in that come in via http push. I comment out the code I think is causing it, stops happening, I put the code back in, still not happening, I leave it for a while, starts happening again. I try and run the engine manually outside the scheduler (so just once instead of every x many minutes), doesnt happen.
Put it back on the scheduler to run a few times, starts happening again. I would google the above error but google doesnt love the + in the search. Anyone have any ideas where to direct me to for this? Its clearly something happening when the rules engine is running but it was more than happily running for weeks before i got back to trying to finish it off. Best thought is that its during the rules engine running it passes events into it one at a time and something is missing that wasnt before.
Really want to know what the + method it refers to is/could be/suppose to be.

Lion previous versions working for restore, but UI bindings not updated after performing restore

I'm working on an app currently, and was scratching my head thinking that previous versions wasn't working; however it turns out that closing the document window and re-opening after a restore the restored values are now displayed.
The problem arises after performing the restore, the UI simply doesn't reflect that a restore has taken place.
Does anybody know of why this could be / how to fix the issue?
Thanks,
Clint
Have you implemented the required API for restoring the UI state of your windows? If you don't know what I'm talking about, you need to read this section of the documentation.
Turns out, it had nothing to do with the restoreFromCoder etc.
It was where the document object was being stamped over each time, this doesn't update the UI as UI updates a performed when a property is set, thus resulting in the binding being invalidated.
The way I got around this, was by every time it loads from a document, it simply "assimilates" the new document objects values into the existing ones (initialised to defaults in init); this results in the UI updating seamlessly when the user restores.