stringWithFormat vs. initWithFormat on NSString

前端 未结 2 505
深忆病人
深忆病人 2021-02-01 20:34

I am wondering what differences such as disadvantages and/or advantages there are to declaring an NSString this way:

NSString *noInit = [NSString stringWithForma         


        
2条回答
  •  春和景丽
    2021-02-01 21:04

    stringWithFormat: returns an autoreleased string; initWithFormat: returns a string that must be released by the caller. The former is a so-called "convenience" method that is useful for short-lived strings, so the caller doesn't have to remember to call release.

提交回复
热议问题