我的方法中有一个 View 对象突然变为 nil 。
我没有使用 ARC
不涉及线程
发生的事情是我第一次调用第一个方法方法一切正常,并且保留了对livecoreSettings的引用。
接下来,当我调用2ndmethod方法时,还保留了 livecoreSettings ref,但是当委托方法被激活时,该变量的引用丢失了..不知道为什么...
@interface XY {
LiveScoreSettingsView * livescoreSettings; // initialisation in .h file inside
}
@end
@implementation
// 1st method
- (void)1stmethod:(id) callingClass username:(NSString*)username {
livescoreSettings=callingClass; // retain count increases to 1
isLivescoresSettingsView = YES;
//.... some code where the above livescoreSettings variables are not used ... //
}
// 2nd method
- (void)2ndmethod:(id) callingClass username:(NSString*)username matchid:(NSString *)matchid eventType:(NSString *) eventType add:(NSString *) add {
livescoreSettings=callingClass;
isLivescoresSettingsView = YES;
addEventToList = YES;
//.... some code where the above livescoreSettings variables are not used ... //
}
// delegate method thats activated when the response comes
- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq {
// the block where the data is sent to a particular view to reload table
else if(isLivescoresSettingsView== YES || addEventToList == YES) {
isLivescoresSettingsView=NO;
addEventToList = NO;
//.... some code where the above livescoreSettings variables are not used ... //
if(success)
NSLog(@"No Errors with retain count = %d ", [livescoreSettings retainCount]);
else
NSLog(@"Error Error Error!!!");
[livescoreSettings.tableView reloadData];
// when **2ndmethod** is called there's no memory reference to livescoreSettings, tableView delegate methods are not called which is obvious. But not sure why the retain count is reducing abruptly.
}
}
@end