Obj-C memory management: why doesn't this work?
        Posted  
        
            by igul222
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by igul222
        
        
        
        Published on 2010-04-09T22:02:50Z
        Indexed on 
            2010/04/09
            22:13 UTC
        
        
        Read the original article
        Hit count: 394
        
Why doesn't the following code work?
MyViewController *viewController = [[MyViewController alloc] init];
[myWindow addSubview:viewController.view];
[viewController release];
As I understand, myWindow should be retaining viewController.view for as long as the window needs it. So why does this cause my app to crash on launch? (commenting out the last line fixes the problem, as expected)
© Stack Overflow or respective owner