real time update plist populate UITableView - iphone

Im trying to create an application that will show in a table 3 floors and in the detailTextLabel show how many computers are available in those floors. For now I dont have the realtime data but I want to just keep some fake fixed data for now and be able to plug in the real data later.
I thought I would create an array, FloorList and FloorListAvailable. Floor list would contain "First Floor" "Second Floor" "Third Floor" and FloorListAvailable would show a number of how many computers are available.
Im currently unsure on how to go about this, it sounds easy enough to do but I cant wrap my head around it. I thought about using NSDictionary. I have used the .plist but can that be changed to by dynamic when I get the real time data?

One possible approach:
generate the realtime data by a script (e.g.); JSON would be a good format
let your app download the data files with a suitable frequency
parse the JSON (see: NSJSONSerialization into own objects; e.g. arrays
use these arrays as the data sources for your table views
whenever you get new data, send reloadData to your table views

Related

How to retrieve data from Parse

Using the parse how to retrieve the data to the table view controller if multiple objects are present.
I tried using the query where receptionist equal to current user.
And I tried find objects in background and append it to an array.
But the problem is all the object values appending to the same array.
Read through the Parse IOS Developer's Guide. It has the information & explanations you need to do this.
http://parseplatform.org/docs/ios/guide/
Also, what you're asking really isn't too clear. Try to specify what specific issues you are having along with posting your actual code next time.

iOS: using GCD with Core Data

at the heart of it, my app will ask the user for a bunch of numbers, store them via core data, and then my app is responsible for showing the user the average of all these numbers.
So what I figure I should do is that after the user inputs a new number, I could fire up a new thread, fetch all the objects in a NSFetchDescription instance and call it on my NSManagedObjectContext, do the proper calculations, and then update the UI on the main thread.
I'm aware that the rule for concurrency in Core Data is one thread per NSManagedObjectContext instance so what I want to know is, do you I think can what I just described without having my app explode 5 months down the line? I just don't think it's necessary to instantiate a whole a new context just to do some measly calculations...
Based on what you have described, why not just store the numbers as they are entered into a CoreData model and also into an NSMutableArray? It seems as though you are storing these for future retrieval in case someone needs to look at (and maybe modify) a previous calculation. Under that scenario, there is no need to do a fetch after a current set of numbers is entered. Just use a mutable array and populate it with all the numbers for the current calculation. As a number is entered, save it to the model AND to the array. When the user is ready to see the average, do the math on the numbers in the already populated array. If the user wants to modify a previous calculation, retrieve those numbers into an array and work from there.
Bottom line is that you shouldn't need to work with multiple threads and merging Contexts unless you are populating a model from a large data set (like initial seeding of a phonebook, etc). Modifying a Context and calling save on that context is a very fast thing for such a small change as you are describing.
I would say you may want to do some testing, especially in regard to the size of the data set. if it is pretty small, the sqlite calls are pretty fast so you may get away with doing in on the main queue. But if it is going to take some time, then it would be wise to get it off the main thread.
Apple introduced the concept of parent and child managed object contexts in 2011 to make using MO contexts on different threads easier. you may want to check out the WWDC videos on Core Data.
You can use NSExpression with you fetch to get really high performance functions like min, max, average, etc. here is a good link. There are examples on SO
http://useyourloaf.com/blog/2012/01/19/core-data-queries-using-expressions.html
Good luck!

Core Data fetch last 50 objects?

Like the native iPhone Messages app, I want to code AcaniChat to return the last 50 messages sorted chronologically. Let's say there are 200 messages total in Core Data.
I know I can use fetchOffset=150 & fetchLimit=50 (Actually, do I even need fetchLimit in this case since I want to fetch all the way to the end?), but can I fetch the last 50 messages without first having to fetch the messages count? For example, with Redis, I could just set fetchOffset to -50.
Reverse the sort order, and grab the first 50.
EDIT
But then, how do I display the messages in chronological order? I'm
using an NSFetchedResultsController. – MattDiPasquale
That wasn't part of your question now, was it ;-)
Anyhow, the FRC is not used directly. Your view controller is asked to provide the information, and it then asks the FRC. You can do simple math to transform section/row to get the reverse order.
You could also use a second array internally that has a copy of the objects in the FRC, but with a different sort ordering. That's simple as well.
More complex, but more "academically interesting" is using a separate MOC with custom fetch parameters.
However, before I went too far down either path, I'd want to know what's so wrong with querying the count of objects. It's actually quite fast.
Until I had proof from Instruments that it's the bottleneck that's killing my app, I'd push for the simplest solution possible.

ios5 core data or pref list

q) what is the best method of storing persons complete details i.e.
steve > details contain :name address,dob, other details etc..
john > details contain :name address,dob, other details etc..
and many more records max would be around 200 tops.
now i want to display these individually and with the option to add them what is the suggested way?
i had a look at core data,userdefaults and NSFileManager but not sure what would be best way to implement such nested texts for save and load.
if you want to search or query them I would always recommend going with core data from the get go.
You'll only end up wishing you add gone down that route in a few months and then would have to factor in a migration.
For core data I use https://github.com/magicalpanda/MagicalRecord for new projects, it does most of the heavy lifting for you.
For a recent app I used NSUserDefaults. Basically keeping all my 'person' objects as NSDictionaries in an NSArray. This suited the app as the data was low, c100 records in use max.
I could just as easily have used a save to disk method, but as I did't have any other use for saving small amounts of preference data, it was just a convenience.
(remember, accessing NSUserDefaults brings back all its contents, not just the particular object you are interested in).
Hope this helps.

Proximity in a Table View?

I'm programming an application that lists a number of locations. I have the coordinates stored in a .plist, which I am using as a data source. I have trouble figuring out how to conceptually approach problems, so some help would help :)
I would like to Have the name of the location sit on the left while on the right of the table view, you can see how far away from the location you are (in miles / kilometers). Is there a convenient way to push this information to the table and sort the list?
You will have to port your plist data into a datasource NSArray for the UITable. You can use sorting functions of NSArray to sort your data at anytime and do refresh on the table. B/c you want non-standard data in the table cell you will have to design your own custom UITableCellView. You can find lot of examples on Stackoverflow on how to create custom cells and do sorting.