【发布时间】:2011-04-10 13:45:04
【问题描述】:
我有两个 ViewControllers
我需要将 NSMutableDictionary 传递给第二个,但正确的做法是什么?
NSMutableDictionary 在第一个视图中被修改并传递到第二个视图,它没有被修改
方法一
- First
@property (nonatomic, retain) NSMutableDictionary * results1;
- Second
@property (nonatomic, retain) NSMutableDictionary * results2;
in First IBAction when iam going to push the second
{
SecondViewController * svc = [[SecondViewController alloc] init];
//svc.results2 is not initialized in Second
svc.2results = [[NSMutableDictionary alloc] init];
svc.2results = [self.results1 mutableCopy];
//in second view did unload i call [results2 release];
[self.navigationController pushViewController:svc animated:YES];
[svc release];
}
方法2
- First
@property (nonatomic, retain) NSMutableDictionary * results1;
- Second with COPY
@property (nonatomic, copy) NSMutableDictionary * results2;
{
SecondViewController * svc = [[SecondViewController alloc] init];
//svc.results2 is not initialized in Second
svc.results2 = [self.results1 mutableCopy];
//in second view did unload i call [results2 release];
[self.navigationController pushViewController:svc animated:YES];
[svc release];
}
【问题讨论】:
标签: objective-c xcode nsmutabledictionary