开发者

Objective-C – Retained property after being set is nil?

开发者 https://www.devze.com 2023-03-24 20:20 出处:网络
I have two classes: A UIViewController and a class that\'s subclassing NSObject that acts as a downloading helper class called OfficesParser. OfficesParser is using ASIHTTPRequest and I set the deleg

I have two classes:

A UIViewController and a class that's subclassing NSObject that acts as a downloading helper class called OfficesParser. OfficesParser is using ASIHTTPRequest and I set the delegate for the download requests to be my UIViewController.

EDIT: Interface for the UIViewController:

@interface OfficesViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, ASIHTTPRequestDelegate> {

    OfficesParser *officesParser;
}

@property (nonatomic, retain) OfficesParser *officesParser;

@end

In the UIViewController implementation I set up the OfficesParser like so:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.officesParser = [[[OfficesParser alloc] init] autorelease]; // self.officesParser is retained
}

Then before the view appears I call my my OfficesParse开发者_如何学Cr object to download some data for me:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.officesParser doNetworkOperations];
}

Also in my UIViewController I have setup the appropriate delegate methods to deal with the data after it has been downloaded. In particular I'm interested in this delegate method that will run after all the data has been processed in my download queue. I can see that the delegate method is running from the log. But for some reason self.officesParser in here is nil.

- (void)queueFinished:(ASINetworkQueue *)queue {
    DLog(@"queueFinished running");

    [self.officesParser test]; // test will not get called because self.officesParser is nil
}
0

精彩评论

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

关注公众号