Blocks中有界面删除操作的时候

在blocks里面做了一个删除的动作,结果内存coredump了.
http://stackoverflow.com/questions/7838442/using-block-callbacks-to-the-...

解决办法就是用一个弱引用,而不是retain self.
__weak id weakSelf = self;

[operation setCompletionBlockWithSuccess:^(KxSMBOperation *operation) {
//[self performSelectorOnMainThread: @selector(finishTask) withObject: nil waitUntilDone: NO];
if (weakSelf)
[weakSelf finishTask];
} failure:^(KxSMBOperation *operation, NSError *error) {
if (!operation.isCancelled)
{
if (weakSelf)
[weakSelf requestFailed:error];
}
}];

另外,如果Blocks有可能对界面操作,需要在主线程中操作.
- (void)downloadFinished {
if (self.downloadComplete)
{
dispatch_async(dispatch_get_main_queue(), ^{
/* Do somthing here with UIKit here */
self.downloadComplete(self);
});
}
}