0

なので、cocos2d フレームワークでゲームを書いています。ロケットが宇宙を飛んでいて、一時停止ボタンに触れたときにすべてを停止する必要があります。このため、私は基本GameObjectクラスでオブザーバーを作成します。

[[Game sharedGame] addObserver:self forKeyPath:@"isPaused" options:0 context:nil];

initメソッドと

[[Game sharedGame] removeObserver:self forKeyPath:@"isPaused"];

deallocメソッドで

Cannot remove an observer <Rocket 0xa3a1c10> for the key path "isPaused" from <Game 0x94a7cc0> because it is not registered as an observer. そのため、シーンを再開しようとするとエラーが発生しました。そして、これをtry catchで試してみると、例外は呼び出されませんが、まだ正しく機能せず、メッセージが表示されます

An instance 0xb1d3380 of class Game was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: <NSKeyValueObservationInfo 0x13c6fa20> ( <NSKeyValueObservance 0xb1b6740: Observer: 0xb120ce0, Key path: isPaused, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0xb1171a0> そして何とか何とか何とか

私は何をすべきか?

よろしく。

4

0 に答える 0