13012013 javascript coffeescript Ti
黒い本の写真アプリをAlloyで作っている。
app/models/photo.jsに
exports.definition = { config: { "columns": { "path": "text" }, "adapter": { "type": "sql", "collection_name": "photo" } } }
とモデルとコレクションを定義しておいて、index.jsで
cameraButton = Ti.UI.createButton systemButton: Ti.UI.iPhone.SystemButton.CAMERA $.win1.rightNavButton = cameraButton cameraButton.addEventListener 'click', -> Ti.Media.showCamera success: (event) -> now = (new Date).getTime() file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, String.format("%d-%d", now, Math.floor(Math.random() * 1000))) file.write(event.media) photo = Alloy.createModel('photo', { path: file.nativePath }) photo.save() Alloy.Collections.photo.add photo return mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
で、写真の撮影は出来てセーブするときにAlloy.Collections.photo.addメソッドがない(というかAlloy.Collections.photoがundefined)というエラーに悩まされている。
130113 追記
index.xmlにCollectionタグを追加したり、なんかごちゃごちゃやってたらうまくいくようになった。エラーの原因は結局わかってない。

高速文字列解析の世界――データ圧縮・全文検索・テキストマイニング (確率と情報の科学)
電子書籍を無名でも100万部売る方法
Real World Haskell―実戦で学ぶ関数型言語プログラミング
Bioisosteres in Medicinal Chemistry (Methods and Principles in Medicinal Chemistry)