iOS Xcode database programming

uba2012

macrumors member
Original poster
Jul 5, 2012
46
0
Denmark
Hey.
I am building an app for my self it's called salary calculator.
I input some data like day, month and hours, minutes worked.
and it calculates the daily earnings and stores it I a database.

I am just wondering how to use databases in objective c. I know how to use them in java which I leaned in school, but I don't understand how to do it in obj c.

I know there is the indirect way (c wrapper FMDB). and one were you access the database directly without FMDB(not core data ). So my question is which way is best if you have experience with it.

I have classes called inputs.m and .h which is a class of setter and getter methods. You know synthesizing. And classes called myinputs l.h and.m. Where I want the methods to write and read from the database to be. I want to follow goos object oriented programming practises just so I can learn from this app.

Thanks in advance for any reply
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I use FMDB. If you use direct sqlite calls you'll find that the difference in memory management between C and objective-C results in a lot of tedious code. This is wrapped up in the FMDB code.
 

uba2012

macrumors member
Original poster
Jul 5, 2012
46
0
Denmark
Do you know how I can make a insert statement with SQL/a method. I should take what it says in a text field and write to a database when you push a button. ?
I use FMDB database
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
It's basically just normal SQL.

There is a file fmdb.m that comes with FMDB and that has sample code in it that shows how to INSERT into a table.
 

uba2012

macrumors member
Original poster
Jul 5, 2012
46
0
Denmark
Thanks I figured it out.
But I seems I can't insert integers into the database.
I use textfields to get data from and save into a integer like this :
Nsinteger day =[dayTextfield.text integervalue];

The program just crashes.