私は内部のブロックの使用と混同されています。私はAppleのドキュメントのいくつかを調べても、正しい答えを見つけることはできません。自己内部の弱い参照を常にブロック内で使用する必要がありますか?
一部の人々は、常に弱い自己内部ブロックを使用すると言いますが、コピーされたブロックでは弱い自己を使用し、常に使用することはありません。
サンプル1:
self.handler = ^(id response, NSError *error)
{
self.newresponse = response; //use weak self here
};
サンプル2:
弱い自己を使用します。
__weak myViewController *weakSelf = self;
[UIView animateWithDuration:interval delay:0.0 options:curve animations:^
{
[weakSelf.view.superview setTransform:CGAffineTransformMakeTranslation(0, -106)];
//in above is it use of weak is neassary
}
completion:^(BOOL finished)
{
}];
弱い自己;
__weak myViewController *weakSelf = self;
[UIView animateWithDuration:interval delay:0.0 options:curve animations:^
{
[myViewController.view.superview setTransform:CGAffineTransformMakeTranslation(0, -106)];
}
completion:^(BOOL finished)
{
}];
正しいサンプルは...? **私はARCを使用しています
可能な複製[\ [self anyFunction \]を\ _ \ _弱いオブジェクト(iOS 5 + ARC)のないブロックで渡すことができる](http://stackoverflow.com/questions/9003600/possible-to-pass- weak-object-ios-5-arcなしのブロック内自己自己機能) – Abizern
また、http://stackoverflow.com/questions/20030873/always-pass-weak-reference-of-self-intoの複製-block-in-arc –