[Titanium mobile]Androidアプリ開発してたらuncaught typeerror cannot call method 'replace' of null

2012/08/31

Titanium Mobile 開発


Titanium mobileでAndroidアプリ開発してて今日のハマったこと。

Stringに大して、replaceをコールしたら以下のエラーが。

uncaught typeerror cannot call method 'replace' of null

iOSは問題なく動くんだけどー。

ソース的には、

var key ="a b(c)d";
alert( key.replace(/[ ¥(¥)]/g,"_") );

こんな感じで発生。

どうすっぺと悩んだけど、

var input = new String(key);
alert( input.replace(/[ ¥(¥)]/g,"_") );

ならちゃんと動きましたよー。

あんまり検証してないけど、メモとして残しておきます。

楽天市場でGO

マウスコンピューター期間限定セール

過去の記事はこちら

QooQ