Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

[Object TIBlob] Response of .toString()

I'm sorry but i've been trying to make sense of this

var templatedata = t.read();
var templatestr = templatedata.toString();

var alertDialog = Titanium.UI.createAlertDialog({
  title: 'Hello',
  message: templatestr, (or templatestr.toString(),doesn't matter )
  buttonNames: ['OK','Doh!']
});
alertDialog.show();

All the alert shows is [Object TIBlob], Shouldn't i be getting the data from the file? preferably in a string

Sorry about this I come from a mainly PHP server life, so typed variables phase me a little bit, brings me back to my high school classes :S

— asked June 8th 2010 by Ryan Tregea
  • android
  • blob
  • javascript
  • mobile
  • tostring
0 Comments

1 Answer

  • Accepted Answer

    You should do it, with .text :

    var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'text.txt');
    var templatedata = f.read();
    
    var alertDialog = Titanium.UI.createAlertDialog({
      title: 'Hello',
      message: templatedata.text,
      buttonNames: ['OK','Doh!']
    });
    alertDialog.show();
    
    — answered June 8th 2010 by Stephane Pelamourgues
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.