objective-c databases...

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

  1. qwerty2k macrumors regular

    Joined:
    Dec 27, 2007
    #1
    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,

    Scott
     
  2. iShater macrumors 604

    iShater

    Joined:
    Aug 13, 2002
    Location:
    Chicagoland
    #2
    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

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #3
    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
    http://en.wikipedia.org/wiki/Core_Data
    http://developer.apple.com/macosx/coredata.html
     
  4. qwerty2k thread starter macrumors regular

    Joined:
    Dec 27, 2007
    #4
    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

    Joined:
    Jul 16, 2007
    #5
    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.

    http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html

    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

    Joined:
    Dec 27, 2007
    #6
    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

    Joined:
    Jul 16, 2007
    #7
    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.

    http://developer.apple.com/document...rial/00_Introduction/chapter_1_section_1.html
     

Share This Page