에 전달할 때 NSMutableDictionary의 새로운 인스턴스를 생성하지만 난 내가 NSMutableDictionary 클래스에서 선언 한 다른 클래스
@interface MyClass0 : NSObject
{
}
@property (nonatomic, strong) NSMutableDictionary *valuee;
@end
및 구현 예를
에 대한 다른 클래스에서의 내용에 대한 액세스를 얻을 인쇄 할 수 없음 내가@implementation MyClass0
- (void)viewDidLoad{
[super viewDidLoad];
[valuee setObject:@"name" forKey:@"Aryan"];
}
@end
지금 나는이
@interface MyClass1 : NSObject
{
}
@property (nonatomic, strong) NSMutableDictionary *dict;
@end
에 액세스 할 MyClass1라는 새로운 클래스를 만들려면 어떻게해야합니까
및 구현
@implementation MyClass1
@synthesize dict;
- (void)viewDidLoad{
[super viewDidLoad];
self.dict = [[NSMutableDictionary alloc] init];
MyClass0 *c = [[MyClass0 alloc] init];
self.dict = c.valuee;
// dict is not nil but the contents inside is nil so it clearly creates a new instance
}
@end
당신은 allocing 당신을 INITING MyClass0하지만보기가 너무 아무것도는 사전에 설정되지지고로드, 안 그래있다. 반면에 귀하의 dict 속성에 대한 사본을 지정했습니다. 그렇습니다. 사본을 작성하고 있습니다. ** 없음 ** - – Remover
나는이 질문을 수정합니다 사고로 복사 넣어 : @Remover –
난 그냥 당신이 감사합니다 :) @Remover –