objective-c databases...

Discussion in 'Mac Programming' started by qwerty2k, Aug 7, 2008.

  1. qwerty2k macrumors regular

    Dec 27, 2007
    Right, so im new to Mac programming (including objective-c), im creating a program to track my poker stats form pokerstars, ive got the text parsing from the hand histories working fairly well so far. However i want to store all the data in a database for faster access/manipulation/storage, anyone recommend/point me in the direction of a database system (postgresql, mysql etc) that i can use to create a database and connected locally via my program and use.

    thanks in advanced,

  2. iShater macrumors 604


    Aug 13, 2002
    I personally use mySQL on my system. CocoaMySQL (not sure of the name) as the GUI client to configure the tables.

    I however use JDBC, so no idea about obj-c.
  3. ChrisA macrumors G4

    Jan 5, 2006
    Redondo Beach, California
    I think what you want is Apple's "Core Data". It's made for exactly the purpose you need. You can have Core Data put your data in a SQLite database

    A multi-user client/server RDBMS like Postgresqlor even mySQL is overkill and not as fast.

    Here are some pointers
  4. qwerty2k thread starter macrumors regular

    Dec 27, 2007
    Had a look at core data, from what i can see, all the documentation shows how to make the app through the data modeling portion of xcode....which is fine, but i can't seem to find any documentation on how to actually communicate with the coredata objects i have created via the xcode gui app, for example i have modelled how my data will look, but i want to in my main.m load data from an external .txt file, parse it and then insert bits of it into the coredata database.
  5. mongrol macrumors regular

    Jul 16, 2007
    Core data is not for those new to Cocoa programming. It can take a while to get your head around as it involves other technologies as well (Bindings for one). The programming guide though, has all the info needed to use it.


    Basically, you "fetch" data objects from the managedObjectContext (that connects to the store) which returns an array of NSManagedObjects. You then operate on them as if its an array of NSDictionary objects.
  6. qwerty2k thread starter macrumors regular

    Dec 27, 2007
    i do appologise in advanced for being 'thick', i have read over the links you provided however they don't seem to offer a solution from what i can gleam for what i want to do (which seems 'simple' in principle).

    I want to model all my data in the model editor within xCode, i then want in my main.m to be able to access the core data store and add 'records' to the core data store via code, for example: [coredata add: playerName, profit]; and then to be able to retrieve the data again, now i know its done with setValueKey and valueKey, however im not sure how to initially connect to my datastore, lookup the player onject and then query that object for the specific piece of information.
  7. mongrol macrumors regular

    Jul 16, 2007
    If you're going to make a GUI then you're not going to put anything in main.m. If you're making a command line utility then you'll want to read this tutorial. It tells you all you need to connect to a store, pull objects and modify them using code. You'll still need to reference the main docs though. I know what you want seems simple but to do it using Core Data you need to read and understand the ManagedObject model stuff. I'm sure there's a way of doing standard SQLite stuff but I don't know it. I'm a developing n00b myself.


Share This Page