Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C Delegates: Have another class I call that parses XML. Need to know when its done externally

I have a class that calls another class to parse (NSXMLParse) from a URL. Now I would like for the class calling this one to know when it has finished, so that I can populate the UI. I am guessing a delegate would be the way to go but ive never worked with one and would need some guidance as to how this would be wired.

Thanks

like image 871
Doz Avatar asked Dec 18 '25 22:12

Doz


1 Answers

NSNotification is, in my opinion, the easiest way to setup something like this.

This is a small snippet from one of my apps:

in method.m when the something I'm processing has finished

[[NSNotificationCenter defaultCenter] postNotificationName:@"GlobalTagsReady" object:nil];

in the class to take care of the notification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getTags) name:@"GlobalTagsReady" object:nil];

where @selector(getTags) is the method to be called

like image 174
James Avatar answered Dec 21 '25 03:12

James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!