开发者

why does this code leak? (iphone)

This is the header:

@interface ForumBrowserAppDelegate : NSObject <UIApplicationDelegate> {
 ForumSelection *forumSelection;
UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet ForumSelection *forumSelection;

(I'm not sure what the nonatomic does, is it something to do with making it safe with multiple threads, do i really need it?)

In the main file:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    // Override point for customization after app launch   

    [window addSubview:forumSelection.view]; //<<<< Instruments highlights this line
    [forumSelection release];
    [window makeKeyAndVisible]; 
}  

Originally I didn't have the property thing in the header or the [forumSelection release]; So I thought that might be why it leaks however Instruments still says this leaks and I have no idea 开发者_JAVA技巧why?


you should not release it where you are doing, instead move the release to dealloc - its not "yours" to release - it was unpacked from the XIB. Doesn't explain the leak.

Are you sure the leak is not in forumSelection ?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜