Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
A new Gideros Studio beta with plugin support is here! - Page 3 — Gideros Forum

A new Gideros Studio beta with plugin support is here!

13»

Comments

  • Thanks, I'll be patient - I got stuck on an event listener.
  • CarolineCaroline Guru
    edited January 2012
    I guess I'm not so patient :) - anyway, I got past that problem, and I was hoping it's possible to write a Core Data plugin.

    (I don't think that a basic UIKit plugin example would cover this question.)

    I've worked out how to create a simple Core Data database in Objective C code so you don't have to set it up through the Xcode xdatamodel, but I'm having trouble creating a Persistent Store (that's where the database actually gets created on disk).

    I get this message:
    *callFile* stack NOT ok begin:1 end:2 delta:-1
    Instead of creating the Persistent Store, I substituted that command with creating a plist file to the same directory, and that was OK, and creating a directory was OK, just not the database Store.

    (This is inside the plugin, so creating a plist in the plugin works.)

    Does that message mean anything to you? And why would this line change the Lua stack when the plugin's not even talking to Lua at that precise moment?
    NSPersistentStore *newStore = 
           [coordinator addPersistentStoreWithType:NSSQLiteStoreType 
           configuration:nil 
           URL:url 
           options:nil 
           error:&error];
    (I checked with NSLogs before and after this line, and it's crashing on this line.)

    My url is created from this string (and I have checked the directories exist and the file doesn't):
    /var/mobile/Applications/A5DF3B7D-0083-42C5-B761-D55325DFF030/Documents/CBCoreData/documents/caroline.sqlite
    Also, if I actually manage to create a database using a plugin, should I be directing it to Documents, or the player's special app subfolder documents?

    ie
    /var/mobile/Applications/A5DF3B7D-0083-42C5-B761-D55325DFF030/Documents/MyAppName/documents
    or
    /var/mobile/Applications/A5DF3B7D-0083-42C5-B761-D55325DFF030/Documents
    Edit:
    Oh, maybe it's threading? I guess I have to do Core Data on the main thread, so it may not be possible to do this at all?
  • atilimatilim Maintainer
    edited January 2012
    The line:
    *callFile* stack NOT ok begin:1 end:2 delta:-1
    means you are leaving the Lua stack dirty. Maybe you forget a lua_pop? But I cannot predict the main crashing reason.

    To get a full path of a file (e.g. "|D|caroline.sqlite") you can add this function to your project:
    const char* g_pathForFile(const char* filename)
    {
        const char* pathForFile(const char* filename);
        return pathForFile(filename);
    }
    and use g_pathForFile("|D|caroline.sqlite");

    This function will return the correct full path of the file at documents folder.

    (Side note: Although rendering is done on a different thread, Lua codes are executed on main thread always)


  • Maybe you forget a lua_pop? But I cannot predict the main crashing reason.
    It seems odd that if I replace that command with a simple write to plist command, then it works fine. I will continue to investigate...
    To get a full path of a file (e.g. "|D|caroline.sqlite") you can add this function to your project:...
    ...Lua codes are executed on main thread always)
    Thanks :).
  • On a related note, |D| will give documents, and |T| will give temp - is there a Library one?

    Or is that |R| for resources?
  • atilimatilim Maintainer
    edited January 2012
    exactly. Both g_pathForFile("caroline.sqlite") and g_pathForFile("|R|caroline.sqlite") are same and return the full path at resource folder.
  • Keep in mind that you can't write to the resource folder. You need to copy your resource to the document folder and work wirth that one. Resources are read only.

    Likes: atilim

    +1 -1 (+1 / -0 )Share on Facebook
  • So there is no writing to the iPhone Library folder? That's where I normally keep my app assets, so that I don't have to put them in the Documents folder. I do iTunes file-sharing with the Documents folder, so I don't want to expose the assets to the end user.

    (By assets, I mean the app's sqlite database, which I don't want the end user to touch)

  • CarolineCaroline Guru
    edited January 2012
    Aside note - OMG! I finally got the Persistent Store creating :) SUE (Stupid User Error) - fileURLWithPath is different from URLWithString b-(. Gideros plugin interface is sooo cool.
  • Which one do you use now? fileURLWithPath?
  • Yes. One of those now-it's-so-obvious moments. But at least I can sleep :).
  • kinduskindus Member
    edited January 2012
    Is it possible to implement g_setRootViewController( UIViewController* myOwnRootViewController);?
  • atilimatilim Maintainer
    edited January 2012
    I cannot predict the side effects when you try to change the root view controller. But you can modify the root view controller of the exported project as you want.
  • Thank you, good idea, but I was going to do it in plugin.
  • atilimatilim Maintainer
    I understand now. Maybe you don't need to replace the root view controller? Does creating your view contoller and adding the view solve your problem?
Sign In or Register to comment.