Object declaration in Objective-C

Posted by Sahat on Stack Overflow See other posts from Stack Overflow or by Sahat
Published on 2010-06-10T05:42:24Z Indexed on 2010/06/10 5:52 UTC
Read the original article Hit count: 445

Filed under:
|
|

Is there any difference in declaring objects in Objective-C between (1) and (2), besides the style and personal preference?

(1) One-line declaration, allocation, initialization.

Student *myStudent = [[Student alloc] init];

(2) Multi-line declaration, allocation, initialization.

Student *myStudent;
myStudent = [Student alloc]; 
myStudent = [myStudent init];

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about object