开发者

Calling back from a child class to the parent class

开发者 https://www.devze.com 2023-02-04 19:54 出处:网络
I have a class that downloads some data from the web. Obviously this can take some time. getTheData = [[GetData alloc] init];

I have a class that downloads some data from the web. Obviously this can take some time.

getTheData = [[GetData alloc] init]; 
[getTheData downloadData];// makes th开发者_如何学Pythone connection to a URL, parses and writes data to an    
array. 
NSString * strHolder = [getTheData.ArrayOfStrings objectAtIndex:0];

If I call all that code in that order then I will get an array out of bounds error. Is there some way in Objective C I can get the GetData class to call back to the parent calling class to tell it that the data download has been completed etc so i can then read from the array and do other tasks than i need to do?

Many Thanks, Code


In your GetData class, create an initWithParent: constructor; store the reference to the parent, and call one of its methods when you're done downloading.

0

精彩评论

暂无评论...
验证码 换一张
取 消