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?
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];
}
It should be possible. Only problem can be with memory management (retain/release), if isn't properly handled.
精彩评论