Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:18:36+00:00 2026-05-25T01:18:36+00:00

I am developing an iPhone application in which I need to use Facebook’s FQL

  • 0

I am developing an iPhone application in which I need to use Facebook’s FQL to load the user’s notifications. As I need to load these notifications different places in the application I would like to make a subclass of NSObject to load and return these notifications as an array.
I understand that I should make a subclass (NotificationLoader) and then I could call a method inside this e.g. startLoading: and in an ideal world this method would just return an array but it cannot, as the notifications should be loaded asynchronous. I also have to take into account that the asynchrnonous request might return an error in connection:didFailWithError:

Can anyone give me a hint or an example of how I can make a class which does an asynchronous load and returns the result? I imagine this class should be called like this:

NotificationLoader *notificationLoader = [NotificationLoader alloc] init];
NSArray *notifications = [notificationLoader startLoading];

Though, I’m not sure that’s the best way to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:18:36+00:00Added an answer on May 25, 2026 at 1:18 am

    If you want it to be asynchronously you should use the delegation pattern. Define a protocol which needs to be implemented by the class which calls the NotificationLoader, When calling startLoading the method should start a separate thread (or using NSURL for starting an asychronous call) and loading all the stuff asynchronously. When it’s done it will call either the ‘finishedLoadingResults:(NSArray*)results’ method on the delegate (which is declared in the protocol) or the ‘didFailWithError’

    so you just call

     -(void) someMethod{
           NotificationLoader *notificationLoader = [NotificationLoader alloc] init];
           notificationLoader.delegate = self;
           [notificationLoader startLoading];
     }
    
     -(void) notificationLoaderDidLoadResults:(NSArray*) results
     {
           // This is the place where you get your results.
     } 
    
     -(void) notificationLoaderDidFailWithError:....
     {
           // or there was an error...
     }
    

    Example for your NotificationLoader:

     @protocol NotificationLoaderDelegate;
     @interface NotificationLoader : NSObject
     @property(nonatomic,retain) id<NotificationLoader> delegate;
     -(void) startLoading;
     @end
    
     // Define the methods for your delegate:
     @protocol NotificationLoaderDelegate <NSObject>
    
     -(void) notificationLoader:(NotificationLoader*) notifloader didFinishWithResults:(NSArray*) results;
     -(void) notificationLoader:(NotificationLoader*) notifloader didFailWithError;     
    
     @end
    

    Implementation of the NotificationLoader

     @implementation NotificationLoader
     @synthesize delegate;
    
     -(void) startLoading{
           NSArray * myResults = ....;
           // Call delegate:
           [delegate notificationLoader:self didFinishWithResults:  myResults];
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iPhone OpenGL application, and I need to use some textures with
I am developing an iPhone application where I need to provide an animation which
I am developing an iPhone application which mainly makes use of the Address Book
I am developing a iPhone application which get facebook album with this URL https://graph.facebook.com/me/albums?access_token=2227470867|2.ZJr73vaEvFeN4fI_A70RFw__.3600.1297090800-100000566543036|WmgxdwULBgKXl8J7ksGIA1tyGik
I am developing an iPhone application in which I want to allow the user
I am developing an iPhone application which requires a multiline text field (UITextView) to
I am developing an iphone application which have a complicated view is to display
I am developing one iPhone application where I need to send some data (in
I am developing an iPhone application which will install few third party applications in
I am developing an application in which I need to find the apps which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.