我有一個View對象在我的方法中突然變爲零。查看對象突然變爲零 - xcode
我沒有使用ARC
沒有線程參與
請告訴我發生的事情是一日一次我稱之爲1stmethod方法的一切工作正常,並於livescoreSettings參考被保留。
下一頁時,我打電話2ndmethod方法也livescoreSettings裁判保留,但由當時的委託方法被激活變量丟失的參考..不知道爲什麼...
@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
是否使用ARC? – trojanfoe
也是'livescoreSettings'的一個實例變量? – trojanfoe
沒有ARC ... livescoreSettings不是一個實例變量..它在.h文件中被聲明 –