Search code examples
multithreadingnsnotification

NSNotification with multithreading XCODE


I am a newbie to IPHONE development. I am facing a issue in working with NSNotification with multithreading.

I have a few images in a gallery.I select the image. Selected images get stored in core data.I have a button (upload). When i click on it i need to show a hud with a NSNotification saying (Uploading with image name). ie. "uploading image1.jpg" then i need to call the next thread to display "uploading image2.jpg" and so on. I need a sample code for this.

I need to know how to send and receive NSNotification with multithreading. Kindly help me in this issue.

Thanks in advance.


Solution

  • Consider using MBProgressHUD for this.

    The demo project include examples very similar to what you're doing. The components also has other feature you may want, like a progress indicator.

    From the main page, configuring an async task to have a HUD notification is as simple as:

    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
        // Do something...
        dispatch_async(dispatch_get_main_queue(), ^{
            [MBProgressHUD hideHUDForView:self.view animated:YES];
        });
    });