我該如何一次運行我的代碼。也就是說,我有一個想要一致執行的代碼。例如:Objective-c中的隊列
- (IBAction)downloadPressed:(id)sender {
//1
CGRect frameDelete = deleteButton.frame;
frameDelete.origin.y = (deleteButton.frame.origin.y-50);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.5];
deleteButton.frame = frameDelete;
[UIView commitAnimations];
[progressLine setProgress:0];
//2 Wait until the code is executed above, and then run the code below
NSURL *fileURL = [NSURL URLWithString:@"http://intercreate.ru/all.zip"];
[self downloadDataAtURL:fileURL];
//3 Wait until the code is executed above, and then run the code below
CGRect frameDelete1 = deleteButton.frame;
frameDelete1.origin.y = (deleteButton.frame.origin.y+50);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration: 0.5];
deleteButton.frame = frameDelete1;
}
也就是說,我希望我的代碼被分爲三個部分:
- 先動旋鈕向上
- 下載文件
- 回落按鈕。
我該怎麼做?