开发者

didReceiveMemoryWarning trouble

What should be in my didReceiveMemoryWarning? I do not see anything I can release that is still in memory. I have a property set up for my managedObjectContext, that's it for ivars.

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIBarButtonItem *calendar = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"calendar.png"]style:UIBarButtonItemStyleBordered target:self action:@selector(viewCal)];
    self.navigationItem.rightBarButtonItem = calendar;
    [calendar release];

    UIBarButtonItem *settings = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gears.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(viewSettings)];
    self.navigationItem.leftBarButtonItem = settings;
    [settings release];

  开发者_如何学JAVA  [SHK flushOfflineQueue];
    [self clearNullWorkouts];
}


- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc that aren't in use.
}


What is in SHK that makes you flushOfflineQueue and what does clearNullWorkouts do? Those may be the kind of resources that you need to free during didReceiveMemoryWarning. Also just because didReceiveMemoryWarning fires that does not mean you have to clean up anything, for instance if you are still displaying the view, playing an audio file that is being referenced, etc. When this called you need to release things like images that are not being displayed, audio that is not being played, etc. After didReceiveMemoryWarning is called view controllers that are not being displayed will have viewDidUnload called and that is where you will set all IBOutlets/programmatic views to nil and release more memory. Apple discusses this in the Memory Management Programming Guide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜