views:

67

answers:

2

Hi, everyone

I want to ask about the passing parameter in objective C on iPhone simulator. Is it possible to pass an parameter (e.g. NSArray) to the delegate method?

I wrote a program, when the user press a button, it will call a function called 'pressLoginButton' (user-defined). After complete the function, I have to pass an NSArray and NSString to the delegate method (connectionDidFinishLoading() in NSURLConnection class). Is it possible to do it?

A: 

It should be possible. Only problem can be with memory management (retain/release), if isn't properly handled.

marko
Thank you for your reply. But how to do it? Would you mind to give me a example for refer?
Questions
+1  A: 
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[self setSavedProp:@"somevalue"];

since the delagate is "self", you can set a property on the current object/self/delegate

now in connectionDidFinishLoading(), access the property which contains the value you wanted

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
   // doSomething with value...
   [self savedProp];
}
Aaron Saunders