自動参照カウントを理解する方法は次のとおりです。
オブジェクトがさまざまなクラスによって消費される場合は、「strong」と入力して、他の人がオブジェクトを操作している間、オブジェクトが残り続けるようにする必要があります。
オブジェクトが単にクラスの内部構造である場合、現在のクラスの実装がオブジェクトの処理を完了するとオブジェクトがなくなるため、「weak」タイプにすることができます。
これ以上のものはありますか?
これが私が想像するものの例です:
#import "World.h"
@interface Foo : NSObject
@property (nonatomic, strong) NSArray *barArray;
@property (nonatomic, weak) NSString *bazString;
@end
@implementation Foo
-(void)sendTheArrayIntoTheWorld {
self.barArray = [NSArray arrayWithObject:@"lonely item"];
[World takeTheArray:self.barArray]; // array is strong so it can exist indefinitely
}
-(void)useThatString {
self.bazString = "weak old string"; // string is weak because it should be discarded when it's no longer needed here...
}
@end