J
J
JohnZoidberg2015-01-28 10:30:21
iPhone
JohnZoidberg, 2015-01-28 10:30:21

How to update View when receiving notification from NSNotificationCenter?

The application has a view controller that is subscribed to notifications. When a certain notification is received, the method changes the text of the text field.
There is a suspicion that a lot of time passes between receiving a notification and directly updating the text.
How to force the view controller to update its view immediately after receiving a notification?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
agee, 2015-01-28
@agee

Doctor, are you sure you are accessing the UI from the main thread and not from a secondary thread? If not, fix it and see if it solves your problem.

R
Reikyavik, 2015-02-06
@Reikyavik

It was noticed about flows correctly, try

dispatch_async(dispatch_get_main_queue(), ^{
        [[NSNotificationCenter defaultCenter] postNotificationName:@"myNotificationName" object:nil];
});

W
warranty_voider, 2015-02-02
@warranty_voider

notification center thing in principle is not fast. Use a delegate whenever possible. When working with NC, make sure that you not only subscribe to notifications, but also unsubscribe from them in time - the same controller can subscribe to the same notification many times, so the handler will be called many times

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question