NSMutableArray arrayWithArray: vs. initWithArray:
问题 These both work in my app without any noticeable difference: 1) theArray = [[NSMutableArray alloc] initWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:theData]]; 2) theArray = [NSMutableArray arrayWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:theData]]; [theArray retain]; However, are they really equivalent? (1) has an alloc statement, whereas (2) does not. Is one preferable over the other? 回答1: The effect is the same. But (2) is less efficient (a convenient method = alloc + init