1
我有一个包含数组对象的数组。阵列阵列。当我将描述方法应用于Array时,我看不到内部数组中的数据。下面是代码:NSMutableArray描述方法 - 阵列阵列
[runScoreDataArray addObject:[NSString stringWithString:currentUser]];
[runScoreDataArray addObject:[NSNumber numberWithDouble:mainScores.scoreTotal]];
NSLog(@"Array1 contains: %@", [runScoreDataArray description]);
// Now add the array runScoreDataArray to the Array highScoresArray
[highScoresArray addObject: runScoreDataArray];
// Empty the runScoresData Array after each run.
[runScoreDataArray removeAllObjects];
NSLog(@"Array2 contains: %@", [highScoresArray description]);
的NSLog的打印输出runScoresDataArray读,因为它应该: 数组1包含:(USER1,34500)
的的NSLog为highScoresArray写着: ARRAY2包含:((),( ),())
我期待在NSLog打印输出中看到每个数组元素的数据,而不是空括号。
问题:如何使用描述方法打印出数组数组的内容?
快速问题:Objective-C数组是引用类型还是值类型? – 2009-12-22 00:31:43
这里使用的数组是NSMutableArrays,其实例是引用。 (Obj-C也支持C风格的数组,但很显然这里没有发生,因为消息正在发送给他们。) – 2009-12-22 00:35:37
我希望得到OP的回复。因为回答这个简单问题的行为会使代码中的错误显而易见。 – 2009-12-22 00:39:28