Search code examples
objective-cios5xcode4

Releasing all buttons that dynamically created in Objective-C


Now i developing IOS application with XCode4.2. i create UIButton when the application run. so my coding is here:

- (IBAction)btnSync_Click:(id)sender {
    float j=10.0;
    for(int i=1;i<5;i++){
        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button.frame = CGRectMake(j, 170, 100.0, 50.0);
        [button setTitle:[NSString stringWithFormat:@"btn%d",i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(btn_Click:) forControlEvents:UIControlEventTouchUpInside];
        [fra_btn addSubview:button];
        j=j+110;
    }
}

- (IBAction)btn_Click:(id)sender{
    UIButton *btntmp=(UIButton*)sender;
    NSLog(btntmp.titleLabel.text);
}

i want to know that i still need to release all buttons inside the fra_btn(View)? if yes how should i do it? my project is ARC project.

Best Rgds, df


Solution

  • Nope, you don't need to release this buttons, and any other objects from CocoaTouch framework created programmatically under ARC.