Hallo,
es wird immer gesagt, dass immer wenn man ein Object mit initWith... initialisiert, dass dann immer ein "autorelease" an das Object automatisch geschickt wird.
Das Object wird also dem obersten "autorelease pool" auf dem Autorelasestack hinzugefügt.
Das Object wird freigegeben, wenn zum pool eine "drain" oder eine "release" nachricht geschickt wird, ansonsten nicht?
Wenn ein Object eine "autorelease" Nachricht erhällt dann wird doch der retain count auf ffff... gesetzt. Also bring mir ein release aufs Object nix?.
Ich habe aber auch gelesen, dass der pool einfach x-mal die "release" Nachricht zum Object schickt, halt so oft wie der retain count vom Object ist, aber da stimmt was nicht oder? der retain count ist doch auf ffff.. gesetzt?
Und noch hier zu(Code aus Doku.. von Apple):
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create the window object and assign it to the
// window instance variable of the application delegate.
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.backgroundColor = [UIColor whiteColor];
// Create a simple red square
CGRect redFrame = CGRectMake(10, 10, 100, 100);
UIView *redView = [[UIView alloc] initWithFrame:redFrame];
redView.backgroundColor = [UIColor redColor];
// Create a simple blue square
CGRect blueFrame = CGRectMake(10, 150, 100, 100);
UIView *blueView = [[UIView alloc] initWithFrame:blueFrame];
blueView.backgroundColor = [UIColor blueColor];
// Add the square views to the window
[window addSubview:redView];
[window addSubview:blueView];
// Once added to the window, release the views to avoid the
// extra retain count on each of them.
[redView release]; //<----------------------------- release
[blueView release]; //<----------------------------- release
// Show the window.
[window makeKeyAndVisible];
}
Die Views werden ja mit einem initWith initialisiert wieso noch ein release?
es wird immer gesagt, dass immer wenn man ein Object mit initWith... initialisiert, dass dann immer ein "autorelease" an das Object automatisch geschickt wird.
Das Object wird also dem obersten "autorelease pool" auf dem Autorelasestack hinzugefügt.
Das Object wird freigegeben, wenn zum pool eine "drain" oder eine "release" nachricht geschickt wird, ansonsten nicht?
Wenn ein Object eine "autorelease" Nachricht erhällt dann wird doch der retain count auf ffff... gesetzt. Also bring mir ein release aufs Object nix?.
Ich habe aber auch gelesen, dass der pool einfach x-mal die "release" Nachricht zum Object schickt, halt so oft wie der retain count vom Object ist, aber da stimmt was nicht oder? der retain count ist doch auf ffff.. gesetzt?
Und noch hier zu(Code aus Doku.. von Apple):
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create the window object and assign it to the
// window instance variable of the application delegate.
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.backgroundColor = [UIColor whiteColor];
// Create a simple red square
CGRect redFrame = CGRectMake(10, 10, 100, 100);
UIView *redView = [[UIView alloc] initWithFrame:redFrame];
redView.backgroundColor = [UIColor redColor];
// Create a simple blue square
CGRect blueFrame = CGRectMake(10, 150, 100, 100);
UIView *blueView = [[UIView alloc] initWithFrame:blueFrame];
blueView.backgroundColor = [UIColor blueColor];
// Add the square views to the window
[window addSubview:redView];
[window addSubview:blueView];
// Once added to the window, release the views to avoid the
// extra retain count on each of them.
[redView release]; //<----------------------------- release
[blueView release]; //<----------------------------- release
// Show the window.
[window makeKeyAndVisible];
}
Die Views werden ja mit einem initWith initialisiert wieso noch ein release?