2:
, , , ivars, iOS 5 , , ARC, iOS 5 , , , Calin , . Q & A QA1758. Calin!
https://github.com/robertmryan/arc-problem-project
Update:
, , vars properties , nil. . ARC, , , , . , , ivar , .
, - . , ( , push-, , ), . ( ) , . , , . , https://github.com/robertmryan/arc-problem-project. , - , . , ( , ), , ARC dealloc .
, , ivars . , , .
#import "ArcTestViewController.h"
#pragma mark - IvarObject
@interface IvarObject : NSObject
@end
@implementation IvarObject
- (void)dealloc
{
NSLog(@"%s", __FUNCTION__);
}
@end
#pragma mark - ArcTestViewController
@interface ArcTestViewController ()
{
IvarObject __strong *_ivarObject;
}
@end
@implementation ArcTestViewController
- (void)dealloc
{
NSLog(@"%s", __FUNCTION__);
}
- (void)viewDidLoad
{
[super viewDidLoad];
_ivarObject = [[IvarObject alloc] init];
}
@end
=nil dealloc, :
2012-07-12 10: 33: 33.644 test4 [36045: 11903] - [ArcSimpleTestViewController dealloc]
, =nil dealloc, :
2012-07-12 10: 35: 23.117 test4 [36083: 11903] - [ArcSimpleTestViewController dealloc]
2012-07-12 10: 35: 23.119 test4 [36083: 11903] - [IvarObject2 dealloc]
, , , deallocs .
Rob Napier provided the sample code below (I appreciate it and others taking my time), but even the code above works fine when I put it in another project, but in my current project it is not freed up properly!
Update from Rob Napier: A simpler example (all in one file) demonstrating how this works. Put this in a file and compile as indicated:
#import <Foundation/Foundation.h>
#pragma mark - IvarObject
@interface IvarObject : NSObject
@end
@implementation IvarObject
- (void)dealloc
{
NSLog(@"%s", __FUNCTION__);
}
@end
#pragma mark - PropertyObject
@interface PropertyObject : NSObject
@end
@implementation PropertyObject
- (void)dealloc
{
NSLog(@"%s", __FUNCTION__);
}
@end
#pragma mark - ArcTest
@interface ArcTest : NSObject
{
IvarObject __strong *_ivarObject;
}
@property (nonatomic, strong) PropertyObject *propertyObject;
@end
@implementation ArcTest
@synthesize propertyObject = _propertyObject;
- (void)dealloc
{
NSLog(@"%s", __FUNCTION__);
}
- (void)assignStuff
{
_ivarObject = [[IvarObject alloc] init];
self.propertyObject = [[PropertyObject alloc] init];
}
@end
int main () {
ArcTest *test = [[ArcTest alloc] init];
[test assignStuff];
test = nil;
NSLog(@"End program");
}