我有下一个代码:
-(void)accountAdded:(GoogleMailAccount *)account
{
DLog(@"accountAdded %@ ",account.emailAddress);
DLog(@"_accounts addObject %@ ",account);
[_accounts addObject:account];
DLog(@"_accounts count %d",[_accounts count]);
[_subFolders setValue:[account subscribedFolders] forKey:account.emailAddress];
[self refreshTableViewTree];
}
以及它的下一个日志输出:
2013-08-02 00:57:28.009 MailClient[9327:11603] accountAdded iosmailclienttest@gmail.com
2013-08-02 00:57:28.010 MailClient[9327:11603] _accounts addObject <GoogleMailAccount: 0x7db94f0>
2013-08-02 00:57:28.011 MailClient[9327:11603] _accounts count 0
为什么帐户大小= 0? (对我来说这是一个真正的问题:(。我什么都看不到???)
答案 0 :(得分:3)
在方法开始时:
if(!_accounts) _accounts = [[NSMutableArray alloc]init];
或者你可以这样做:
-(NSMutableArray *)accounts
{
if(!_accounts) _accounts = [[NSMutableArray alloc]init];
return _accounts;
}