Access a file from within iOS module?

You must Login before you can answer or comment on any questions.

I stored image.png in my Resources folder in Titanium app. I want to access to that file from within iOS module.

-(void)setTextureFile:(TiFile *)value 
{
    ENSURE_TYPE(value, TiFile);
    textureFile = value;
 
    CC3Texture* texture = [CC3Texture textureFromFile:value.path];   
}
this gives me error:

[ERROR] Script Error = *** +[NSString stringWithCString:encoding:]: NULL cString at app.js (line 31).

What is the correct way to to those things?

— asked 12 months ago by Dino Bartosak
2 Comments
  • you are going to need to show more than just the module code, how are you passing the file in?

    — commented 12 months ago by Aaron Saunders

  • I found a way after trying everything:

    JS code

    mesh.texture = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'beastie.png');

    -(void)setTexture:(id)value
    {   
        ENSURE_SINGLE_ARG(value, TiFile);
        ENSURE_UI_THREAD(setTexture, value);
     
        texture = value;
     
        mesh.texture = [CC3Texture textureFromFile: [value path]];
    }
    I was passing before just a string value to module.

    — commented 12 months ago by Dino Bartosak

Your Answer

This question has been locked and cannot accept new answers.