Objective-c app can't read sql database - ios

so the fight with this tutorial goes on.
I made my own database(techbase.sql) and inserted two people into it - one of them with name of marian, adress menda and phone 112.
This application should log out in text fields: name, adress and phone from database when I input persons name into name field.
Saving properties into new database created "dynamically" in app works. But reading from db at start of the app doesn't.
What may be the problem? Have i specified name of db wrong? Or maybe the database table is made wrong?
Here is my project http://speedy.sh/D6hau/techtopiatut-3.zip if you would like to look in.
Thanks you in advance!
Just in case if this is confusing I will write easier:
-techbase.sql has two people in it
-cant log out their phone and adress by putting in name when I start app(like cant read db or something)
-can save and then log out but I want to read from pre-maid db. Not from table made in app.

Select your .sql database on the Xcode files list and then, in the right side, check that the Target Memership is correct (your target should be checked).

Related

SQLite fmdb: If I can't delete a column, would deleting the column data be okay?

I currently have an SQLite table that contains the user's information (first name, last name, age, IP address).
However, I don't want the App to store the IP address anymore. The only solutions that I seem to have are to create another table and transfer all the data to it or just delete the address data (set it to NULL). I choose setting it to NULL because it seems easier and the App works very well when I do this with no repercussions. Also, I made it where if the user logs in, the IP address column isn't even going to exist.
My concern is if there is any reason why I shouldn't do this at all? I haven't run into any issues yet, but just in case I thought I'll ask.
Edit: Forgot to mention this, but there is only 1 row of data for the user.
The answer is: you don’t need to drop the column. It’s too much unnecessary work for 1 row of data.
You won’t have any issues because of that spare column
You can “drop” it pretty easily if you like, by just creating a new table with a single row, it sounds scary, but you’ll be surprised with the short time it takes you to do it.

Shipping a new SQLite database in app update

Our app will ship with a pre-populated database which continually downloads updates from our production server's database to stay up to date. When we make updates to our app's codebase and push those updates out to the AppStore we'll also include an updated db.sqlite file.
My questions is: when we do this I assume it will overwrite the users "old" database file that already exists?
I assume (and hope) the answer is yes, but just wanted to double check - I couldn't find any answers in Apple's documentation, but might have simply overlooked, or have been looking for the wrong terminology.
When you say "which continually downloads updates from our production server's database" I assume that means the app will download the data and update the database? In which case the database must exist in the Documents folder and it won't get into the Documents folder until you copy it there.
Normally this is done by the app if the database file doesn't already exist, however if you want to overwrite the current database you'll need a mechanism to discover if the one in the Documents folder is out-of-date, compared to the one in the app bundle. This probably means having a "metadata" table (with two columns name/value) containing a version number or some such. You read both databases and decide whether or not to copy.

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!

Results returned from Prestashop do not match given values in plist...expected behaviour?

I have created a mobile app using appixia for an existing site...our existing site has existing users, who have put their existing addresses into our database (prestashop/mysql).
One of these fields (Address Line 2) has been used for the UK County (similar to US States). As this was free text entry, users have used abbreviations etc in this field.
My mobile app I have generated, I want to use a plist for the users to select their county. This would work well for new users.
For existing users logging in, when prestashop returns their "county", and it DOESNT match a given value in the plist, what is the expected behaviour? This is difficult for me to simulate, but I would expect it to leave the field blank if no value sent from prestashop matches a plist value?
Just to make sure I understood correctly, you are building your plist according to this example, and in the Value fields you don't use a numerical value (like the example) but instead put the text of the county name. Since the Prestashop Address Line 2 is free-text, this works out and fills-in the name that you put in the Value.
If there isn't a full match to the user's current address, the expected behavior is either to leave this field empty or use the first selection value from the list. Not sure which is it, I suggest you test it out :) It's shouldn't be that hard to simulate, create a user in Prestashop through the website or the website backoffice and set a random value to Address Line 2. Then login using this user in the app. Another idea is to create a user in the app, and then using the website backoffice edit his address and change Address Line 2 to some random value, and then login once again through the app.
In any case, between login and re-login, it's best to restart your app (or the Visualizer), to make sure cookies are deleted and you're logged out.

How to handle multiple database accesses?

In my program I have multiple databases. One is fixed and cannot be changed, but there are also some others, the so called user databases.
I thought now I have to start for every database one connection and to connect to each data dictionary. How is it possible to connect to more than one database with one connection by handing over the data dictionary filename? Btw. I am using a local server.
thank you very much,
André
P.S.: Okay I might find the answer to my problem.
The Key word is CreateDDLink. The procedure is connecting to another data dictionary, but before a master dictionary has to be set.
Links may be what you are looking for as you indicated in the question. You can use the API or SQL to create a permanent link alias, or you can dynamically create links on the fly.
I would recomend reviewing this specific help file page: Using Tables from Multiple Data Dictionaries
for a permanent alias (using SQL) look at sp_createlink. You can either create the link to authenticate the current user or set up the link to authenticate as a specific user. Then use the link name in your SQL statements.
select * from linkname.tablename
Or dynamically you can use the following which will authenticate the current user:
select * from "..\dir\otherdd.add".table1
However, links are only available to SQL. If you want to use the table directly (i.e. via a TAdsTable component) you will need to create views. See KB 080519-2034. The KB mentions you can't post updates if the SQL statement for the view results in a static cursor, but you can get around that by creating triggers on the view.

Resources