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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:14:37+00:00 2026-05-15T08:14:37+00:00

I have a two classes, a controller called AppController and a class called URLDelegate

  • 0

I have a two classes, a controller called “AppController” and a class called “URLDelegate” that encapsulates the sample NSURL code from Apple’s URL Loading System Programming Guide.

The guide repeatedly mentions declaring the receivedData instance variable “elsewhere.” I assume this means outside of the URLDelagate class, because if I declare it in the URLDelegate class, my controller class can’t “see” the data that has been downloaded.

I know that data is received, because in my connectionDidFinishLoading function, I have NSLog display the results:

NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
receivedText=[[NSString alloc] initWithData:receivedData encoding: NSASCIIStringEncoding];
NSLog(@"receivedText=%@",receivedText);

So I’m a bit stumped with the following questions:

  1. Where should I declare receivedData? My controller class? A third class?
  2. Can I just declare it like any normal NSMutableData variable?
  3. How do I give my URLDelegate class “access” to this variable? E.g., if I declare receivedData in my AppController class, wouldn’t I have to instantiate AppController within URLDelegate? But how would this possible if it’s the AppController class which is instantiating the URLDelegate class in the first place?

Especially with regard to the last question, I feel like I must be overlooking something blindingly obvious and fundamental. If anyone could point me in the right direction, I would really appreciate it.

Thank you!

Update: I moved all of the NSURL functions out of their URLDelegate class and placed them in my controller class. I’m now able to update variables in my controller class from the connectionDidFinishLoading. This seems a bit hacky to me, but it works.

  • 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-15T08:14:37+00:00Added an answer on May 15, 2026 at 8:14 am

    1. Where should I declare receivedData? My controller class? A third class?

    It has to be declared in the same class as that method for that method to use it. From your question, it sounds like that class is your URLDelegate class. Since it’s explicitly explained in the comment as “an instance variable”, “elsewhere” must be that class’s own header, in the class’s instance-variables block.

    2. Can I just declare it like any normal NSMutableData variable?

    Yes. See the relevant chapter of The Objective-C Programming Language.

    3. How do I give my URLDelegate class “access” to this variable?

    Classes cannot access instance variables in their instances, since they are instance variables; by definition, they are part of—and, therefore, only accessible to—the instances.

    Instances access their instance variables as they would any local or global variable, as demonstrated in the sample code you referred to:

    receivedData = [[NSMutableData data] retain];
    

    receivedData is the instance variable you’d declare in your URLDelegate class. Note that you simply use the name “receivedData” by itself; you do not need to use any special syntax to refer to an instance variable rather than another variable. For this reason, avoid giving a instance variable and a local variable the same name.

    There are a number of ways you could make the data available to the app controller. A simple one would be to expose a property of the URLDelegate, but that leads to the question of how the app controller should know to retrieve or re-retrieve the value of the property. A more comprehensive list of solutions is in the “Communicating with Objects” chapter of the Cocoa Fundamentals Guide.

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

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 443k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Based on the AuthUserFile line, it looks like you're using… May 15, 2026 at 6:09 pm
  • Editorial Team
    Editorial Team added an answer aha: I think I found it: http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f1-32495.html Controlling Axes Size… May 15, 2026 at 6:09 pm
  • Editorial Team
    Editorial Team added an answer In this line: g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(applyIngresarDados), &dados); you pass a… May 15, 2026 at 6:08 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.