//結論:method的參數是assign,也就是不做copy直接傳入指標
//確認參數的指標為copy或assign
NSMutableArray *array = [@[@1,@2] mutableCopy];
[concept checkParameterPointer:array];
NSLog(@"array : %@", array);
+ (void) checkParameterPointer:(NSMutableArray *)array{
NSMutableArray *a = array;
NSLog(@"1. a=%@", a);
[a addObject:@5];
NSLog(@"2. a=%@", a);
}
//執行結果
2014-05-22 18:15:40.349 ConceptComfirm[47546:60b] viewDidLoad
2014-05-22 18:15:40.362 ConceptComfirm[47546:60b] class : Concepts
2014-05-22 18:15:40.363 ConceptComfirm[47546:60b] 1. a=(
1,
2
)
2014-05-22 18:15:40.363 ConceptComfirm[47546:60b] 2. a=(
1,
2,
5
)
2014-05-22 18:15:40.363 ConceptComfirm[47546:60b] array : (
1,
2,
5
)
2014-05-22 18:15:40.389 ConceptComfirm[47546:60b] viewWillAppear
2014-05-22 18:15:40.448 ConceptComfirm[47546:60b] viewDidAppear
沒有留言:
張貼留言