objective c - Multiview app memory leak warning. -


I created a multiviapp app based on this. This is my code appdelegate.h

  @class Disclaimerviewcontroller; @ Interface GAINSAppDelegate: NSObject & lt; UIApplicationDelegate & gt; {Disclaimer Controller * First view; } @ Property (Nonomatic, Retaining) IBOutlet UIWindow * Window; @property (nonatomic, retained) Disclaimerviewcontroller * firstview; - (zero) switchviewview: (UIView *) View 1 overview: (UIView *) view2; I have the following in @end   

and ".m"

  - (BOOL) Application: (UIApplication *) Application FinishLaunchingWithOptions: (NSDictionary * ) Launchoptions {// Override Point after application launch [auto Windows and knowledgeable]; Disclaimerviewcontroller * aview = [[Disclaimerviewcontroller alloc] initWithNibName: @ "Disclaimerviewcontroller" bundle: zero]; Self.firstview = aview; [_window addSubview: aview.view]; [Overview]; Yes come back } - (zero) switchviewview: (UIView *) View 1 overview: (UIView *) View 2 [[UivView startup permissions: @ "animation" reference: zero]; [UIView Set Animation Duration: 0.50]; [UIView Set Animation Transition: UIViewAnimationTransitionFlipFromLeft forView: self.window cache: yes]; [View1 removeFromSuperview]; [_window addSubview: view2]; [UIView commitAnimations]; }   

and dealloc

  - (zero) Delok {[first view release]; [_Windows release]; [Super DeLoc]; }   

Since I want to switch to another view, I use the following code

  - (IBAction) switchtodisclaimer2: (id) sender {GAINSAppDelegate * delegate = (GAINSAppDelegate *) [[UIApplication shared application]]]; Disclaimerviewcontrller2 * Disclaimer = 2 [[Disclaimerviewcontrller2 alloc] initWithNibName: @ "Disclaimerviewcontrller2" bundle: zero]; [Representative switch view: self.view Overview: Disallow. 2. View]; }   

Just like the tutorial. But when I analyzed the test, there is possible memory leak in the code above the X code warning. So I added (in the case above) [disclaimerview2 release]; And when I run the program, I get the EX_BAD_ACCES error since I thought it was with the name, it was an autorelage? now I'm confused. The tutorial does not address all this on

The rule for memory ownership is:

If your method name starts with 'alloc', 'init', 'copy', 'mutablecopy' or 'new', they are responsible for issuing it, either release With or autorelease

yes, you have a memory leak, so you should issue 'Disclaimer View 2' with 'codeay' [Rejection Release 2]

However, the reason F you crash that caused elsewhere bug in your code.

If you are going to pass it in your representative, your representative should retain it - otherwise, try to use it at some point in the representative future, but It will be canceled.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -