Creating a budget app (not for release, just something quick & dirty) and I noticed upon starting the Master-Detail template that Apple uses Core Data and NSFetch results to populate the tables (think Notes on an iPad).
My inexperienced and unprofessional programming instincts wouldn't think twice about grabbing an NSMutableArray, taking the names of the table cells and cramming them into an index, saving that as an NSUserDefault and then upon reloading the app, populate each cell at it's current index with the same index in the NSMutableArray so the contents is back where the user left it. Just wondering, how inefficient is this compared to using Core Data?
On a side note, any easy way of communicating between two different tables that both hold dynamic data?
Up to a few hundred records, don't worry about it. It would be indeed wonderfully "quick and dirty".
Still, the learning curve for Core Data is not as steep as you might expect. Once you get the hang of it - and your simple app is great way to explore that API - you will find that you want to do everything with it. Even large projects will seem easy.
Your choice.
Related
IOS newb working on app that pulls JSON feed from web server into an IOS app.
Is it best practice to create an API (in PHP in my case) that spills all the records--which could be thousands into a JSON feed and have the IOS app handle all of them (though displaying only one screen at a time)?
Or is best practice to limit the results in the JSON feed to say ten or one hundred and then have some user action in the IOS App draw down the next batch?
The first would seem more desirable given the reusable cell concept, however, it seems that sending huge numbers of records is bound to be slower and/or problematic from a web traffic and memory management point of view.
On the other hand, the second seems really complicated. How would you know which page to pull down based on IOS style gestures.
Looking to learn best practice on this as it seems to be common for many apps.
Many thanks for any suggestions.
It probably depends on your use case. If you have a lot of data then you probably wouldn't want to load all of them at once. At a certain point it will take too much time and you probably have to do that more than once if you don't persist or if you want to refresh.
In that case a good API is designed to be iterated over e.g. limit/offset parameters. Meaning for example the user scrolls a list of items and when scrolling to the bottom of the list you fetch a new batch of items.
In the other case where one call is fast enough to deliver all the data at once there is no reason to make it more complicated as you said and you can still add iteration afterwards.
I'm creating an app that manages mileage. There are pre-set miles for each route (there are 28 locations with routes between each, the mileage is set for each).
I am trying to 'preload' a database table with those routes/mileages so that when the user tracks a new route they've gone (say point A to point B) the app can easily figure out how many miles the user traveled with a quick query.
I've done website development and am familiar with mySQL - but there are some GUI's that I use to preload that data (phpmyadmin); there doesn't seem to be anything similar with the iOS that I can find so I can preload the mileage data into a table (entity?) so I can work on creating the interface to work with that data.
How should I go about achieving this? I am hoping to use core data to achieve this if possible - although SQLite seems like another options some have mentioned. But even others mentioned just holding that data in an array. Being so new to iOS programming - I'm just looking for a solid way to accomplish a pre-loaded database table.
Per the comment from Aaron Brager - using this tutorial I have went with Core Data
http://www.raywenderlich.com/12170/core-data-tutorial-how-to-preloadimport-existing-data-updated
Alrighty,
I am new to Xcode so I apologise if I am missing any key points here.
But, I want to have a large list in a UITableView type display. The list will be an array of strings with maybe 500 ish entries and a search bar to search for what ever entry you like. Once found you can tap the entry and it will load a detailed view of what ever it is. I would prefer to not have to have all of the data entry in Xcode and am wondering what would be the neatest way to store/read/write this?
I am leaning towards some sort of data file... but couldnt quite work out how to implement this into Xcode. I have searched around a bit but couldnt find anything which made sense (probably because i am quite new to Xcode).
This will be an App for iOS.
Any ideas?
I understand that you want to create a UITableView displaying static data and your problem is that you don't want to store the data in your code. Depending on how complicated the structure of your data is you could save it in a sql database, store it with coredata, keep it in a xml file or keep it in a file in a custom encoding. I don't quite now where your Problem lies. You can just load the file/database, parse it in an object structure and display it in the tableview. There are a couple of advantages of using a database to a file:
You can create connections easily and handle them without a lot of effort
You only need to load in the memory what is really needed at the moment.
Core data will be fine for you. However if you don't need all of its extra functions and the list will be static (eg, non changing and will be read into the code at runtime in its entirerty) then you can probably use a plist. Plist data can be read directly into arrays.
I am developing a relatively simple new free iOS app. As it's free I decided to go straight for iOS 5 as a target to allow me to try out some new features, particularly story boards.
Once I've got my head around them storyboards are wonderful, I've written hardly any boilerplate code at all up the point of a working prototype.
My model at the moment is is non persistent, after all it's just a prototype, but I've started to wonder about the best way to make it persistent. The model consists of essentially a list of custom objects which contain text, images and locations.
And so to the questions.
If I have a fully working model in memory is there a relatively simple to convert that into a persistent core data representation ?
If I want to have synchronisation to a backend web service at some point will this help ?
Should I start again with a core data application and throw away the prototype ?
All depends on your data set. If you have a large graph with relationships, Core Data might be a good idea. For simpler data sets, you could write it out to a .plist in the user's documents directory. For very small amounts of data, you could persist them into NSUserDefaults.
I am writing an iPad app that will be expandable with new items via in-app purchasing. For example, my current plan is to have a jpg pattern and a matching plist file with the parameters I need to expand that pattern into a full picture.
The user will select one jpg/png from a list of small thumbnails - the list is held in Core Data - and the app will find the matching plist for displaying the jpg/png correctly. I'll only have about 10 of these open at one time. But I could end up with storing 1000s of jpgs and plists.
Does storage of lots of small files cause app problems?
I'm going the plist way, rather than storing the parameters in Core Data, so that if I need to add parameters later, I don't have to migrate the database, just change the access in code. (And when I'm creating the patterns, it's easier to concentrate on a plist file rather than a Core Data row.)
The app seems to work really well at the moment, but I'm worried about futures...
My app does also use Core Data for other things, so I could change over if the app will get bogged down with number of files.
Thanks.
Saving a large number of small files is not a problem as long as you have a well thought out means of naming and tracking the files.
Remember that the user does not have the same flexibility and ease of file management on a mobile as they do on non-mobile platforms. Designs that work on non-mobiles are unworkable on a device used on the move with one finger.
However, when you say:
And when I'm creating the patterns,
it's easier to concentrate on a plist
file rather than a Core Data row.
... the use of "row" suggest that you haven't fully grasped Core Data's utility. Core Data doesn't use rows, columns, tables or joins. It's an object graph management system that sometimes uses SQL way behind the scenes.
Core Data is designed to handle data in a way that meshes seamlessly with the rest of the object oriented API for the UI and other services. When you use other data management systems like plist, you will most likely end up manually duplicating a lot of Core Data's functionality anyway.