小编Shi*_*sad的帖子

是否有必要在块内使用弱引用自我...?

我对使用自我内部块感到困惑,我浏览了一些Apple的文档,但仍然无法找到正确的答案.

有些人总是说在块内部使用弱自我,但有些人说在复制的块中使用弱自我,而不是总是使用.

样本1:

self.handler = ^(id response, NSError *error)
{
    self.newresponse = response; //use weak self here
};  
Run Code Online (Sandbox Code Playgroud)

样本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)
{

}];
Run Code Online (Sandbox Code Playgroud)

没有弱小的自我;

__weak myViewController *weakSelf = self;

[UIView animateWithDuration:interval delay:0.0 options:curve animations:^
{
    [myViewController.view.superview setTransform:CGAffineTransformMakeTranslation(0, -106)];

}
completion:^(BOOL finished)
{

}];
Run Code Online (Sandbox Code Playgroud)

在上面的样本中,哪些是正确的......?**我正在使用ARC

cocoa cocoa-touch objective-c-blocks

43
推荐指数
2
解决办法
1万
查看次数

如何在iOS中使用AVFoundation压缩视频

iPhone中是否有任何压缩技术可以使用AVfoundation压缩视频.或任何开源.

此致,Jeeva

cocoa-touch avfoundation ios

0
推荐指数
1
解决办法
8559
查看次数