2012-11-29 25 views
0

我在我的iOS項目中使用的方法之一獲取內存泄漏。由於我是iOS開發新手,因此無法瞭解發生了什麼。我的iPhone應用程序項目中存在內存泄漏,我應該如何解決它?

http://screencast.com/t/y2lOtssY2NjO

+2

您正在初始化您的UIAlertView兩次。它應該是[[UIAlertView alloc] initWithTitle ...]或者只是[UIAlertView alloc](沒有init),然後在稍後調用指定的初始化器(就像你現在這樣做)。 – 2012-11-29 08:59:44

+0

對於一個格式良好的問題+1。將來請確保將圖像直接添加到SO,而不是將其發佈到其他網站上。如果有任何相關的代碼,請將其發佈。 –

+0

k。我會。謝謝 – Nishi

回答

3

要調用初始化您alertView兩次。 我認爲這是問題所在。

變化,像:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:str message:kAlertMessage delegate:self cancelButtonTitle:nil otherButtonTitles:@"Install now", @"Cancel", nil]; 

請參考這個問題:What happens if i call init more than once

+0

謝謝。泄漏被刪除。 – Nishi

+0

@Nishi:很高興:)感謝您的評論。 –

0

您可以通過儀器發現這裏是教程click here會告訴你或Xcode->產品 - >分析

+0

謝謝。我已經嘗試過,但我沒有得到適當的解決方案,實際上是由於泄漏造成的。 – Nishi

1

static analyser指向了泄漏上UIAlertView .Initialize的alertView只有一次。

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:str .....等等

+0

Thanks.Leaks已被刪除 – Nishi

相關問題