3

違いは何ですか

 NSNumber *number = [[NSNumber alloc]initWithInt:13];

NSNumber *number = [NSNumber initWithInt:13];

両方が同じ目的を解決するのに、なぜ割り当てるのですか?

4

2 に答える 2

12
于 2013-03-25T16:11:31.630 に答える
2

Graham Lee already gave the correct answer that's why you should accept it as the correct one. Nowadays, in my opinion [NSNumber numberWithInt:42]; is just a short cut of [[NSNumber alloc] initWithInt:42]

于 2013-03-25T16:31:04.567 に答える