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

  • SEARCH
  • Home
  • 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 9250899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:33:38+00:00 2026-06-18T10:33:38+00:00

In my app i am sending a request to server . The request is

  • 0

In my app i am sending a request to server .
The request is in some other class-called requestClass, and is being called from the main view class. (i am using cocos2d).

My question is, how would i informed the main class (from the requestClass ) that the operation is done ?
When it finish the request-its callback is in its own class(requestClass) and the NSLog is done IN the requestClass .

i dont think NSNotification is the right way

requestClass is like :

[NSURLConnection
     sendAsynchronousRequest:request
     queue:[[NSOperationQueue alloc] init]
     completionHandler:^(NSURLResponse *response,
                         NSData *data,
                         NSError *error)
     {

         if ([data length] >0 && error == nil)
         {
             **// HOW SHOULD I INFORM THE CLASS THAT CALL ME NOW ???**

         }
         else if ([data length] == 0 && error == nil)
         {
             NSLog(@"Nothing ");
         }
         else if (error != nil){
             NSLog(@"Error = %@", error);
         }

     }];
  • 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-06-18T10:33:40+00:00Added an answer on June 18, 2026 at 10:33 am

    OK, to write a delegate protocol…

    Assuming your connection file is called MyRequestClass.

    In MyRequestClass.h…

    @protocol MyRequestClassDelegate <NSObject>
    
    - (void)requestDidFinishWithDictionary:(NSDictionary*)dictionary;
    
    //in reality you would pass the relevant data from the request back to the delegate.
    
    @end
    
    @interface MyRequestClass : NSObject // or whatever it is
    
    @property (nonatomic, weak) id <MyRequestClassDelegate> delegate;
    
    @end
    

    Then in MyRequestClass.h

    [NSURLConnection
         sendAsynchronousRequest:request
         queue:[[NSOperationQueue alloc] init]
         completionHandler:^(NSURLResponse *response,
                             NSData *data,
                             NSError *error)
         {
    
             if ([data length] >0 && error == nil)
             {
                 [self.delegate requestDidFinishWithDictionary:someDictionary];
    
                 //you don't know what the delegate is but you know it has this method
                 //as it is defined in your protocol.
             }
             else if ([data length] == 0 && error == nil)
             {
                 NSLog(@"Nothing ");
             }
             else if (error != nil){
                 NSLog(@"Error = %@", error);
             }
    
         }];
    

    Then in whichever class you want…

    In SomeOtherClass.h

    #import "MyRequestClass.h"
    
    @interface SomeOtherClass : UIViewController <MyRequestClassDelegate>
    
    blah...
    

    In someOtherClass.m

    MyRequestClass *requestClass = [[MyRequestClass alloc] init];
    
    requestClass.delegate = self;
    
    [requestClass startRequest];
    

    … and make sure to write the delegate function too…

    - (void)requestDidFinishWithDictionary:(NSDictionary*)dictionary
    {
        //do something with the dictionary that was passed back from the URL request class
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I recognise server communication to my app without intiating or sending any request
In my app I am sending a request to the web server and getting
I am sending some information from my application to server and waiting for the
I'm developing a client/server app that will communicate via rest. Some custom request data
My app is sending users email with the following: https://blah.chacha.com/feedback/##comment-reply-169 But for some reason,
I am developing an app for sending some feedback. Basically I'm trying to make
I am using core location framework inside my app and sending updated location to
I'm developing a web app integrated with facebook and I'm using the request dialog
I'm writing a web app that is sending some straight files in response to
When I open the app from background I need to hit server to get

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.