以下のメソッドを使う
|
1 2 3 |
@interface NSObject - (BOOL)respondsToSelector:(SEL)aSelector; @end |
|
1 2 3 |
handler.cleanUp = ^(){ [self.logger writeLog]; }; |
|
1 2 3 4 5 6 7 |
__weak type(self) weakSelf = self; handler.cleanup = ^(){ __strong type(self) strongSelf = weakSelf; // 処理中に解放されないように保持する if (strongSelf) { [strongSelf.logger writeLog]; } }; |

|
1 |
$ screen |
|
1 2 3 4 |
$ screen -ls There is a screen on: 2597.pts-0.GLANTANK (Detached) 1 Socket in /var/run/screen/S-admin. |
<PID>.<tty>.<host>
TypeScript 2.0にて、tsdはdeprecated(非推奨)に変更。typingsを代替ツールとして推奨。特別なツールは不要でnpmでも管理可能。
|
1 |
$ npm install --save @types/electron |
*.tsのソースコードにおいて reference path を記述して型定義ファイルを読み込む必要なし。(tsdを使っていないにもかかわらず読み込もうとするとエラー)
|
1 |
$ npm install tsd -g |
|
1 |
$ tsd install github-electron --save |
|
1 |
$ tsd query github-electron -rosa install |
Canvasに描画するときはonloadハンドラにて実行する
|
1 2 3 4 5 6 7 |
var ctx = document.getElementById('myCanvas').getContext("2d") var img = new Image() img.src = "myDog.png" ctx.drawImage(img, 0, 0) |
※上手くいくときもある。
|
1 2 3 4 5 6 7 8 9 |
var ctx = document.getElementById('myCanvas').getContext("2d") var img = new Image() img.src = "myDog.png" img.onload = function() { ctx.drawImage(img, 0, 0) } |
ローカル画像に限らない。
canvas.toDataURL()で画像を生成したときも同様。
node.jsのパッケージ管理をHomebrewからnodebrewに移行するための前準備
|
1 2 3 4 5 6 7 8 9 |
$ cd /usr/local/lib $ npm uninstall npm - abbrev@1.0.7 node_modules/npm/node_modules/abbrev - ansi-regex@2.0.0 node_modules/npm/node_modules/ansi-regex - ansicolors@0.3.2 node_modules/npm/node_modules/ansicolors ... - write-file-atomic@1.1.4 node_modules/npm/node_modules/write-file-atomic - npm@3.6.0 node_modules/npm |
|
1 2 |
$ brew uninstall --force node Uninstalling node... (31,538 files, 340.8M) |
Homebrewでインストールしたnode.jsのアンインストール
|
1 |
$ curl -L git.io/nodebrew | perl - setup |
|
1 |
$ nodebrew install-binary latest |
|
1 2 3 4 |
$ nodebrew list v5.7.0 current: none |
|
1 |
$ nodebrew use v5.7.0 |
|
1 2 3 4 |
$ nodebrew list v5.7.0 current: v5.7.0 |
npmはnodeと一緒にインストールされる
|
1 2 |
$ npm -v 3.6.0 |
|
1 2 |
$ which npm /Users/JaneDoe/.nodebrew/current/bin/npm |
|
1 |
$ git clone https://github.com/atom/electron-quick-start |
|
1 |
$ cd electron-quick-start |
|
1 |
$ npm install && npm start |
npmではプロジェクトのルートディレクトリにおいたpackage.jsonでモジュール(ライブラリ)のインストール管理をするため「プロジェクトの初期化」と「package.jsonの作成」は同義。
|
1 |
$ npm init |
npmで管理するプロジェクトの情報はpackage.jsonに書き込まれる。
package.jsonはテキストエディタで編集可能であるが、初回は対話式コマンドで作成するのが簡便。
|
1 |
$ npm install <module name> |
|
1 |
$ npm install electron -g |
|
1 |
$ npm install electron-prebuilt -g |
The prebuilt Electron binaryのパッケージ名変更のおしらせ
http://electron.atom.io/blog/2016/08/16/npm-install-electron
|
1 |
$ npm install electron-packager -g |