You*_*sef 5 objective-c uiviewcontroller ios objective-c-blocks
我正在研究Iphone应用程序(ios5 + storyboard + arc).我有2个ViewControllers A和B.
在AI有一个按钮.当我按下时,我向服务器异步提交请求(使用AFNetworking),我将使用performSegueWithIdentifier(push not modal)转到View Controller B.
当请求完成时,它执行一个请求成功的Block,它将数据保存到数据库.(该块在ViewController A中,因为请求是从那里发送的)
有没有办法可以通知ViewController B请求已经完成并在B中执行方法?
我正在寻找的是当请求完成并进入成功块时,我在视图控制器B中运行一个方法,它是加载的视图.
我希望我很清楚.
谢谢
Mid*_* MP 13
要发布通知,请使用以下代码:
[[NSNotificationCenter defaultCenter] postNotificationName:@"Midhun" object:nil];
Run Code Online (Sandbox Code Playgroud)
在通知监听类的viewDidLoad中添加观察者:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(performTask:) name:@"Midhun" object:nil];
Run Code Online (Sandbox Code Playgroud)
performTask: 是在观察通知时将调用的方法.
请参阅NSNotification Class Reference