Some beginner Objective-C/iPhone questions

前端 未结 5 488
终归单人心
终归单人心 2020-12-31 21:01

I\'m just starting out (reading up a lot for the past couple of days). Here\'s some questions that I have stacked up, hopefully someone can answer them.

1.

5条回答
  •  被撕碎了的回忆
    2020-12-31 21:14

    1: This check is to ensure that the super constructor returned a new object.

    2: Static methods don't refer to an instance

    3:

    str = @"Hi there!"

    This assigns the address of the constant string "Hi there!" to the pointer str

    str = [[NSString alloc] initWithString:@"Hi there!"];

    This allocates a string and copies "Hi There!" to it. This means that a) str is modifiable and b) needs to be deallocated when you are done with it.

提交回复
热议问题