• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: newbie question: NSURLConnection delegation and "method instance"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie question: NSURLConnection delegation and "method instance"


  • Subject: Re: newbie question: NSURLConnection delegation and "method instance"
  • From: Dmitri Goutnik <email@hidden>
  • Date: Mon, 21 Jul 2008 01:24:28 +0400


On Jul 20, 2008, at 11:43 PM, JB Ashton wrote:

Hi all,

I'm struggling with "receivedData is declared as a method instance
elsewhere" in this explanation of NSURLConnection delegation:
http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

When I declare the receivedData as NSMutableData in the delegate's header
file, I get this warning from the compiler: "warning: local declaration of
'receivedData' hides instance variable".


Where should I declare the receivedData variable so that it is available to
all the delegation methods (connection:didReceiveResponse:, etc.), but won't
be hidden by the local declaration above? Won't local declarations in each
delegate method refer to different NSMutableData objects?


Many thanks,
JB

Without seeing the source code, I'm just guessing here - are you declaring receivedData as method local variable in the same method where you calling [[NSURLConnection alloc] initWithRequest:delegate: ?


You should declare it in delegate header and just use it in delegate methods, otherwise local declaration would indeed hide the instance variable.

@interface ConnectionDelegate : NSObject {
	NSURLConnection	*connection;
	NSMutableData		*receivedData;
}

@implementation ConnectionDelegate

- (void)setupConnection {
// ...
connection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (connection) {
receivedData = [NSMutableData new];
// ...
}
}


@end

- Dmitri

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >newbie question: NSURLConnection delegation and "method instance" (From: "JB Ashton" <email@hidden>)

  • Prev by Date: Re: newbie question: NSURLConnection delegation and "method instance"
  • Next by Date: Re: NSThread and UI
  • Previous by thread: Re: newbie question: NSURLConnection delegation and "method instance"
  • Next by thread: Core Data Sync Question (Managed Object Contexts)
  • Index(es):
    • Date
    • Thread