Spliting strings
Hi I've been having some problems with my string splitting thingy.
My server is returning me a string (encoded in base64) that I want to transform into an array with the split function but whenever I use the standard javascript string.split("delimiter") my android app crashes, after reading through some documentation I see that there's also a Titanium.Blob.split("delimiter")function but alas that also crashes my app.
server outputs something along these lines:
id###gps_coord_lat###gps_coord_lng###uuid
and these are the ways I tried to make it work
var dresponse = Titanium.Utils.base64decode(this.responseText);
var drespondejs = dresponse.split("###");
*crash*
and
var dresponse = Titanium.Utils.base64decode(this.responseText);
var bytes = Titanium.Api.createBlob(dresponse);
var drespondejs = bytes.split("###");
*crash*
I had various alerts sprawled around the code for debugging purposes and I've narrowed down to the string splitting zone and I would be very thankful if someone could help me.
Thanks in advance
EDIT: I've also made a quick change on the server output so it barfs out something like:
[id,gps_coord_lat,gps_coord_lng,uuid]
but when I try to eval the result it also crashes, can somebody tell me what am I doing wrong? :(
1 Answer
-
Thanks for the answer Vineet…it worked perfectly for me! :)