iOS: Store names in a plist - ios

It's been years since I've done iOS, but I'm jumping back into it and have a quick, beginners question. When the app launches, it will launch with a search field. You type in a persons name, hit enter, and info about the name will appear. I'm thinking about storing all the most common names in a plist, and having the search run through the plist after the user hits "enter", then display info about the name they typed in. This is where I'm stuck. After you type in the name and hit enter, I have no clue about how to make it display the info about the name, or even where to store data about the name. Any help is much appreciated, thanks!

I'll give you half of the answer you need here, the "loading" and "saving" part.
The "plist" you're talking about here is actually an array of names.
And -- how handy! -- "NSArray" has both an "initWithContentsOfURL:" method and a "writeToURL:atomically:" method.
Any more than just a few names and people will start suggesting using Core Data.
Also, if you want to be able to change and/or save the names while the app is running, you'll need to use a "NSMutableArray" instead of an immutable array.
As for the displaying part, you should probably learn how to use table views (UITableView) and binding (i.e. you "bind" to the array and values get displayed based on whatever the user typed into the search field). There are lots of tutorials and examples on this, as well as related questions here on StackOverflow.

Related

Apple Watch Complication extension

I'm creating a Complication for Apple Watch and I've came across a doubt.
For now, I've set an Array of 5 entries for the timeline, and everything is working correctly.
my question goes, what happens when the request returns nil, like after the 5 entries were displayed?
Does the Watch refreshes itself and executes all of the delegate methods again to populate the entries, or does it stops working because it hasn't more information to display since the 5 entries were displayed already?
If so, is there any way of adding another entry to the end of the array itself? When the first entry of the array has passed is there a way for me to append a new one to the end of it, so I'd get always 5 entries to display and the app wouldn't run out of information to display?
It could sound confusing, but I hope you'd get what I meant to say, hope my English is understandable.
Kind regards.

Local storage on Rails

I've built a Rails app, basically a CRUD app for memos/notes.
A notes title must be unique. If a user enters a name already taken a warning message is shown prompting them to chose another.
My question is how to make this latency for this feedback as close to zero as possible. When creating a note little UX speed bumps like this will get annoying for user quickly.
Of course the main bottleneck is the network. Inspired by Meteor (and mini-mongo) I was thinking some kind of local storage could be a solution?
I.E. When app first loads, send ALL JSON to the client with ALL note titles. The app (front end is Angular JS) could check LocalStorage (or App Cache, Web SQL?) instead of incurring a network round trip. The feedback would be instant.
I've used LocalStorage in the past to augment an app, but in the scenario it'd really seriously depend on it. I'm not sure how confident I'd be building on something that user might not have. Also as the number of user Notes/Memos I have doubts how feasible it is to send a JSON object down the wire with ALL the note titles. That might get pretty big. On the other hand MeteorJS seems to do this with no probs.
Has anyone done something similar or have any pointers? Thanks!
I don't know how Meteor works here, but you're right that storing all note titles in localStorage is not a good idea. Actually, you don't need localStorage here, you can just put it in a JS array, because you need this data only once (when checking new note title).
I think, there could be 2 possible solutions:
You can change your business requirements and allow non-unique title. Is there really a necessity for titles to be unique?
You can verify note title when user submits form. In this case you can provide suggestions for users, so they not spend time guessing vacant title.
Or, if titles must be unique only within a user (two users can have same title for their notes), you can really load all note titles in JS array and check uniqueness while users types in a title.
Or you can send an AJAX request checking title uniqueness as soon as user finished typing the title. In this case you can win some seconds.
Or you can send an AJAX request as soon as user typed in 3 symbols. The request will return all titles that begin with these 3 symbols, so you don't need to load all the titles.

Creating you own database with Parse for an iOS app in Swift

I need to know if I can use Parse for what i need. Let me give you some context. I am new to coding for iOS in Swift. I am creating an app, and a big part of it is displaying info to the user depending on what country they select.
So at the start of the app, they will select a country. I have used Parse a little bit through an online course, so I know how to signup and create users etc.
What i want to know if i can do?
Can i use Parse to create my own database? So have a Class called country_data, and then in that class, have all the countries with info about them. As an example of what i mean, see the table below:
Then, in the app, i can check that if the user selects 'Spain' for example, I can display all the Info for Spain.
Everything i've done in Parse so far had been about sending info to Parse that Ive created from the code in Xcode. But i need to know if i can go into my app in Parse and create this database myself.
Is this possible and is it the right way to do what i'm looking for. Any suggestions welcome, and thanks! Please ask questions if you need me to explain more.
Nick
Good news OP,
(1) yes Parse is absolutely perfect for this.
Parse is now at http://back4app.com
Here...
It literally took me less time to do that, than it took to answer your question!
It's almost unbelievable to understand how much time "BAAS" services save, in the new "BAAS" era.
(2) 196 countries. You should be OK :) Anything up to a few million countries will work fine. After that Parse will get a little slow on searches.
(3) "But I need to know if i can go into my app in Parse and create this database myself."
Yes, using the internet and a computer,
just go to back4app.com, log in, and click on your project. Click on "Core". (Parse software also offers features like Analytics, etc. For the database system, just click on "Core".)
Notice the button "Add Class", click that and type in "Country". Add a column called "name" which is a "String".
Make another new class "City". Again make a "String" column "name", and also make a column that is a "Pointer" to "Country".
You're completely done.
It is far quicker than me typing it here, heh

Change JSON values from iphone app (possible API needed?)

I have an app with tutorials. I also have a tab where users can suggest tutorials. Right now, the app loads a table view with an JSON array taken from my website. Every tutorial object in the array looks like this:
{"string" : "Tutorial Name", "value":1, "devices":["deviceid1","deviceid2"]}
The string is the name of the tutorial they want to see. The value is how many people have voted for it. The devices is an array of strings where I would save the device ID of each user who votes for that tutorial. This is to make sure they do not vote more than once.
Now, what I want the app to do is to change the value key to add one and to add its deviceID to the array.
How do I do that in xcode? I am assuming I might have problems with 2 users trying to change the values at the same time. Should I maybe create a small API for this? Possible create a file that would get the values for me and change them as well?
If so, how do I go about doing this?
Thanks!
If you are making changes to the JSON from your app, you are only changing the values locally. This means that the changes won't be updated on the devices of other users who are accessing the app. I think the best way to do this would be to create a small API.
1) You will need to setup a MySQL database that has keys for "string" and "value".
2) Create a PHP script that takes in a string and then adds one to the value field of the database row. This script will be called when a user "votes" for a tutorial.
3) Create a PHP script that queries the data from the database and converts it to JSON format. When loading the app, this script would be called and your app would parse the JSON data and display it into a tableview with the updated values.
Hope this sets you off in the right direction!

Data Entry for iPad Help Needed

I am searching for a way to take the current text written in a text box and transfer that to a list, and after the list is full, send that list to an e-mail.
To make better sense of this, I'll explain. I help out at a youth ministry where the kids are required to check-in at the door. Instead of writing names down on paper, I have been tasked with designing an app so they can just type the name on an iPad. Once the kid hits "Submit" button, I would like their first and last name (different text boxes, but could conjoin if easier to code) to be added to a never-ending rtf file or something of the sorts. This rtf file would then be e-mailed to me so I could keep an online roster.
I have all the buttons and fields in place, I just cannot figure out how to code the submit button to handle the function of placing the current text from the linked boxes in a separate file. If it can't be rtf, I don't really care. Just wanting something I can e-mail back to my Mac to save time. If anyone knows how to do this, or somehow finds a site that I missed during my continued scouring of the Internet, please let me know your solutions.
Blessings,
Kyle Baity
You can have an NSMutableArray to which you add new name strings as they are submitted, you can then make this into a string list using componentsSeparatedByString:. This allows you to sort and count the names easily if you want to add more features later on.
It's not clear how you want the email to be sent, but MFMailComposeViewController would be a good start, using your list string as the message body.

Resources