Grand Central Dispatch (GCD) and blocks make multi-threading easy. However, there are some lesser-known techniques that benefit your next project.
![Grand Central Dispatch Design Patterns](https://cdn-ak-scissors.b.st-hatena.com/image/square/ebd80a8bfe928ec95c6d0ec490a6ff0195dde7fd/height=288;version=1;width=512/https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fgcdpresentationsep2011-120118215930-phpapp01-thumbnail.jpg%3Fwidth%3D640%26height%3D640%26fit%3Dbounds)
ふと気になったので実験してみた。 Objective-Cの@synchronizedは、つまりはmutexらしい。 Appleのドキュメントに書いてあった。 例えば、 @implementation Singleton @synthesize count; static Singleton* singleton = nil; + (id)sharedObject{ if (!singleton) { singleton = [[Singleton alloc]init]; singleton.count = 0; } return singleton; } - (void)increment{ count ++; NSLog(@"%d",count); } @end こんな感じでシングルトンなオブジェクトを用意して、incrementをGCD使って10万回呼んでみた。 Singleton
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く