คำถามติดแท็ก nsautoreleasepool

7
กลุ่ม NSAutoreleasePool autorelease ทำงานอย่างไร
ที่ผมเข้าใจสิ่งที่สร้างขึ้นกับalloc , ใหม่หรือสำเนาความต้องการที่จะได้รับการปล่อยตัวด้วยตนเอง ตัวอย่างเช่น: int main(void) { NSString *string; string = [[NSString alloc] init]; /* use the string */ [string release]; } คำถามของฉันมันจะไม่ถูกต้องเท่านี้หรือ: int main(void) { NSAutoreleasePool *pool; pool = [[NSAutoreleasePool alloc] init]; NSString *string; string = [[[NSString alloc] init] autorelease]; /* use the string */ [pool drain]; }
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.