Objective-C Memory Management: crash on release

前端 未结 5 1412
情深已故
情深已故 2021-01-29 00:07

I\'m new to Objective-C and can\'t seem to get the memory management code right. I have the following code:

Media* myMedia = [self.myMediaManager getNextMedia];
         


        
5条回答
  •  死守一世寂寞
    2021-01-29 00:13

    The general rule for memory management is as follows:

    For every retain, alloc, copy, or new, you need to call release or autorelease.

    Since you did not call any these, you do not need to release myMedia.

    For more information, take a look at this other answer I posted that deals with the subject. Also, since you are new to iOS development, I suggest looking at this answer as well.

提交回复
热议问题