我有3个方法,我希望逐个完成所有的执行。
它可能是使用块完成但我无法学习如何创建自己的块。或者还有其他方法可以达到这个目的吗?
我的情景是,
同样的情况没有块和&一切都在ios6中正常运行但os低于不工作
[self getIndex];
[self expandrows]; //I want this expandrows to be called only after everything in getIndex is finished.
-(void)getIndex
{
[self didSelectRowAtIndexPath:indexPath];
//Once this didselect is completed execution than after only i want to start this loop
for (int index = 0; index < [tableView numberOfRowsInSection:0]; index++)
{
NSMutableDictionary *aMutDicCur = [self.model itemForRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]];
if([[aMutDicCur valueForKey:@"CategoryId"] intValue] == 4)
{
indexPath = [NSIndexPath indexPathForRow:index inSection:0];
break;
}
}
//After this loop finishes i need to again call one other method
}
据我所知,块是异步的。所以在那种情况下
答案 0 :(得分:3)
调用此[self expandrows];在你完成第二个方法调用之后,在
中调用获取索引方法。