Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Waldo Giron
681 PointsInitializing with NSNumber
Having this declared:
NSNumber *mike;
Does this..
mike = [[NSNumber alloc] initWithInt: 23];
do the same thing(alloc and init) as this?
mike = @23;
2 Answers
Waldo Giron
681 PointsRight on! That was perfect, nice documentation. Thank you!!!
Justin Horner
Treehouse Guest TeacherHello Waldo,
You are correct in that setting the mike variable to a number literal, such as @23 in this case, will call [[NSNumber alloc] initWithInt:23]. You can read more about Objective-C literals here.
I hope this helps.
Aaron Daub
Courses Plus Student 207 PointsObjects created through literal syntax are autoreleased.
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherYou're welcome! Glad I could help.