NSNumber Literals

前端 未结 5 1602
南方客
南方客 2020-12-18 09:32

I am very new to Objective-C. I know C and C++ but Objective-C has quite the learning curve. Anyway, is there a shorter way (possibly by some kind of NSNumber literal if suc

5条回答
  •  囚心锁ツ
    2020-12-18 09:49

    Two things in addition to the previous responses, both of which are correct:

    First, it'll be easier for us to help if you follow Cocoa naming conventions: variables, including object pointers, should start with a lower case letter. So, 'tyler' instead of 'Tyler'. Classes and types start with upper case letters.

    Second, you'd never autorelease an object before you initialize it. Always alloc first, then init, and then do whatever else you need to do, including release or autorelease.

提交回复
热议问题