开发者

Default iPhone template

开发者 https://www.devze.com 2023-01-05 05:53 出处:网络
The default iPhone view template has code as follows {// Override point for customization after app launch

The default iPhone view template has code as follows

{    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}

isnt there a memory leak here? shouldnt it be

{    

    // Override point for customization after app launch    
    [window addSubview:viewController.view];
    [viewController.view release];
    [window makeKeyAndVisible];

    开发者_StackOverflow中文版return YES;
}


There is no memory leak. You shouldn't call [viewController.view release] either.

The main reason is because the app delegate is not the owner of that .view. Only owners are responsible for -release'ing an object. The owner of that .view is the viewController.

(In general, you should never call -release on a property.)

0

精彩评论

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

关注公众号