There are two ways of initializing objects in Objective-C, i.e.:
1) AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
2) AVCaptureSession *session = [AVCaptureSession new];
Seems like they are doing the same job. What is the difference between them? Or “new” it is just a novelty of iOS5?
Would be grateful for the answer,
Artem
newis a shortcut way of doing an alloc/init that should work on any object, but it’s mainly a hangover from Smalltalk andnewcalls never take arguments so you don’t see it used much at all any more.So the two should be identical and it’s a novelty but not of iOS 5.
EDIT: further to this,
newis defined onNSObjectas something that callsallocand theninitand is given as having been available since Mac OS X 10.0 (which is the beginning of time as far as Apple’s documentation is concerned).