What does @“some string” mean in objective-c?

前端 未结 3 938
感情败类
感情败类 2021-01-17 18:13

I\'m just starting out with iphone development and ran across some example code that used @\"somestring\"

someLabel.txt = @\"string of text\";
3条回答
  •  庸人自扰
    2021-01-17 18:26

    Just an interesting side note... NSString literals created by using the @"..." notation are not autoreleased. They essentially just hang around until your program terminates.

    Just a caution that if you want to maintain control over whether or not this object gets released (freed) down the road you may want to consider using something like:

    [NSString stringWithString:@"..."]; 
    

    ...instead. This would create an autoreleased version of the same string that will be freed from memory next time the "autorelease pool is drained".

    Just food for thought.

    Cheers-

提交回复
热议问题