I am getting memory leaks in one of the method which I used in my iOS project. I am not able to find out what is happening as I am new in iOS development.
Asked
Active
Viewed 63 times
1
-
2You're initializing your UIAlertView twice. It should be [[UIAlertView alloc] initWithTitle...] or just [UIAlertView alloc] (without init), then call the designated initializer later (like you're doing it now). – Nov 29 '12 at 08:59
-
+1 for a well formatted question. In future make sure that you add the images directly to SO rather than posting it on other sites. If there is any related code please post that too. – Midhun MP Nov 29 '12 at 10:14
3 Answers
4
You are calling init twice on your alertView. I think that makes the issue.
Change that like:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:str message:kAlertMessage delegate:self cancelButtonTitle:nil otherButtonTitles:@"Install now", @"Cancel", nil];
Please refer this question : What happens if i call init more than once
1
The static analyser
is pointing out the leak on UIAlertView
.Initialize the alertView only once.
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:str
.....and so on

AppleDelegate
- 4,269
- 1
- 20
- 27
0
You can find via instrument here is tutorial for click here that will tell you or Xcode->product->analyze

SachinVsSachin
- 6,401
- 3
- 33
- 39
-
Thanks. I have tried but I am not getting proper solution where the leaks actually cause. – Nishi Nov 29 '12 at 09:02