Do I need a release at dealloc?

In the book I'm learning for iPhone dev, they use instances IBOutletusing Interface Builder. An example is UIButton. Therefore, they add a thing to the structure as follows:

 IBOutlet UIButton *whateverButton;

Then they add a @propertyfor each of them in .h and a @synthesizein .m.

Then they include a releasein dealloc.m. Two questions:

  • Is a release required? Not all properties are already processed automatically?
  • How can I check the number of links to see what happens for debugging purposes ...?
+3
source share
3 answers

Is a release required? Not all properties are already processed automatically?

, . @property @synthesize, , , , dealloc .

, IBOutlet - Interface Builder, , IB. , Cmd-click IBOutlet, :

#ifndef IBOutlet
#define IBOutlet
#endif

IBAction, void.

, , ...?

, dealloc . retainCount , - .


, @synthesize . @property @synthesize , - :

@property(retain) NSString *foo;
@synthesize foo;

- (void) foo {
    return foo;
}

- (void) setFoo: (NSString*) newFoo {
    // Try to think what would happen if this condition wasn’t
    // here and somebody called [anObject setFoo:anObject.foo].
    if (newFoo == foo)
        return;
    [foo release];
    foo = [newFoo retain];
}

, , . , dealloc.

+5

. , , , . . - "" . . - . , .

, , , . , - , , , .

Apple Cocoa. , . , (, , , , , - , ).

+5

? ?

, . (@synthesize 'd), , . Obj-C Cocoa, . post , .

, , ...?

NSObject saveCount. . NSZombieEnabled, , , , , , .

+3
source

Source: https://habr.com/ru/post/1734909/


All Articles