0
我试图在数组可用时将通知放入数组中,但是当我推送新通知时,数组的计数重置为1。获取具有通知的数组
这是代码:
int r = 0;
listMsgReceived = [[NSMutableArray alloc] init];
if (notification)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Notification received" message:[NSString stringWithFormat:@"%@", message] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
[listMsgReceived insertObject:message atIndex:r];
r++;
NSLog(@"apres: %d \n", [listMsgReceived count]);
}
看起来你可能在每个通知之前使用一个局部变量'r'来设置为0,但很难确定代码是否有限。 – Stonz2
是的,你是对的。谢谢 ! – user3866054