Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOscar de la Hera Gomez
1,775 PointsParse.com, AFNetworking 2.3.1 and CoreData
Hi All !
I have recently been building a geolocation app using the Ribbit project as a base and I am now trying to transfer the Parse Users to a CoreData model to optimise the image/contact loading procedure.
I have ran into a series of tutorials including:
http://www.raywenderlich.com/15916/how-to-synchronize-core-data-with-a-web-service-part-1
http://www.raywenderlich.com/59255/afnetworking-2-0-tutorial (updated to iOS7)
and
https://www.parse.com/questions/using-afnetworking-with-parse-rest-api-for-post
However, all these tutorial are either out of date, do not give enough information or are too difficult to translate to iOS7. I am now starting to read about Parse caching policies but I am not sure this is the right solution.
All I want to do is take my current user and his friends and cache their information and images on the disk to optimise the app and update this once a day. Additionally, I would add/remove users to this cache if they were added or removed from the friends relations.
Finally, I would clear the cache when the user would log out.
Can anyone help me ?
2 Answers
Guilherme Juraszek
3,550 PointsParse cache system is really poor. I've used it in a few projects and had to replace it with Parse + Manual Core Data syncronization. Parse released a new framework for offline sync for Android and they said they will release a version for iOS soon. Since you want to just cache few data I think the easy solution would be just save a plist (xml) file with a custom class User.
I made one simple application that I wrote a few months ago available at https://github.com/guidefreitas/smartquotes
The app is also available at App Store - Quotees - https://itunes.apple.com/us/app/quotees/id818547836?l=pt&ls=1&mt=8
It uses Core Data + Parse. It also uses multi core data context to update the core data objects in a background thread. This way the user interface is not blocked while synchronizing the data from Parse.
Oscar de la Hera Gomez
1,775 PointsHeres the Parse release !
Oscar de la Hera Gomez
1,775 PointsOscar de la Hera Gomez
1,775 PointsThanks for the reply ! Why is it really poor ? And did you use any tutorials for Parse + Manual Core Data sync ? And do you know approximately when they'll release the iOS add-on ?
Guilherme Juraszek
3,550 PointsGuilherme Juraszek
3,550 PointsWhen I use it I found that when you add a new object it sometimes it does not invalidate de cache and you get the wrong data. You need to clear the cache manually and pull the data again. I didn't use any tutorial, I just create a Core Data managed object (like the one teached here in threehouse course) and create a "proxy" class. I edited my post with a sample app that I wrote a few months ago, it uses core data and syncs with Parse. It also uses multiple data contexes to allow core data manipulation in the backend thread (to not block the main thread, and the user screen, when adding, deleting or updating the core data objects).
Guilherme Juraszek
3,550 PointsGuilherme Juraszek
3,550 PointsThis book describes the Core Data multi context technique http://www.amazon.com/Learning-Core-Data-iOS-Applications/dp/0321905768/ref=sr_1_1?ie=UTF8&qid=1407518467&sr=8-1&keywords=learn+core+data
This post also helps http://www.cocoanetics.com/2012/07/multi-context-coredata/
Oscar de la Hera Gomez
1,775 PointsOscar de la Hera Gomez
1,775 PointsThanks