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 6145221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:45:46+00:00 2026-05-23T18:45:46+00:00

I’m working on app, which sends and receives JSON data using NSURLConnection, but I

  • 0

I’m working on app, which sends and receives JSON data using NSURLConnection, but I have this connection and its delagate methods inside viewcontroller, and that’s not correct for MVC I guess. I’ve wanted separated class for whole connection, but there was problem that I couldn’t detect then in viewcontroller, when the connection finished loading, so I couldn’t get received data. What is the correct way to do this ?

However, this hole (non MVC) NSURLConnection inside viewcontrollers works fine for my app, except one case – when I need to use tableview, which is part of viewcontroller – which is also datasource and delegate for this tableview. It seems like tableview is trying to create cells, before connection finished loading, which is little bit weird I think, because in method tableView:numberOfRowsInSection: I already have data I need, and I thought that this method is called before I’m configuring cell in tableView:CellForRowAtIndexPath: …but I’m wrong probably. Can somebody explain me what’s going on here and how to solve this ? (also the first part with correct using of MVC with NSURLConnection)

  • 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-23T18:45:47+00:00Added an answer on May 23, 2026 at 6:45 pm

    Implement a delegate protocol for your JSON client class, e.g.:

    @protocol JSONClientDelegate <NSObject>
    ...
    - (void) connectionFinishedLoading;
    ...
    @end
    
    @interface JSONClient
    {
        id<JSONCLientDelegate> delegate;
    }
    @property (nonatomic, assign) id<JSONClientDelegate> delegate;
    -(void) getJSON;
    @end
    
    @implementation JSONClient
    
    - (void) getJSON
    {
        ...
        [NSURLConenction connectonWithRequest:request delegate:self];
        ...
    }
    
    - connectionDidFinishLoading:(NSURLConnection*) connection
    {
        [delegate connectionFinishedLoading];
    }
    
    @end
    

    Then, have your viewcontroller implement the delegate protocol:

    @interface MyViewController : UIViewController <JSONClientDelegate>
    ...
    - (void) doFoo;
    ...
    @end
    
    @implementation MyViewController
    
    - (void) doFoo
    {
        ...
        JSONClient* client = [JSONClient new];
        client.delegate = self;
    
        [client getJSON];
        ...
    }
    
    - (void) connectionFinishedLoading
    {
        // Connection finished - do things here.
    }
    
    @end
    

    Note that this is an extremely abbreviated example – I’ve cut a few corners to save some space. I trust you can read between the lines and fill in the gaps – if not (i.e. my example is unclear), let me know and I’ll elaborate further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
I have thousands of HTML files to process using Groovy/Java and I need to

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.