嗯,我有一個UITextField。管理UITextField.text屬性
它內部是一個屬性UITextField.text。
它是確定的事情:
// Assume we have UITextField * tf somewhere..
// now set its text..
tf.text = [ [ NSString alloc ] initWithUTF8String:"Init'd with utf8" ] ;
我這個問題是內存。 會將UITextField的文本屬性的舊值發生什麼情況。
不要你必須做的:
// maintain reference to old NSString
NSString * oldTfText = tf.text ;
// set the value to the new value you want
tf.text = [ [ NSString alloc ] initWithUTF8String:"Init'd with utf8" ] ;
// release the old NSString now..
[ oldTfText release ] ;
我還在想着內存MGMT的像我這樣在正常C.這可能是這裏的缺陷。