如何通过方法返回传递 NSMutableArray。
我让它传递数组“空格”,所以一个由 10 个对象组成的数组传递了 10 个 block ,但这些对象中不包含任何信息。
提前致谢
编辑:基本上我创建了另一个包含路径信息的类,因为我的 Controller 有点困惑。所以这个新类我想调用返回 NSMutableArray 的“create”方法。该数组在路径类中创建得很好,但是当 return 语句触发时,它只传递空格而不传递值甚至是指针。
目前是
return path;
我试过了
return &path;
并且失败了。
Edit2:不幸的是,这是我遇到的问题。
仍然崩溃
打电话
newNode = [newNode copy];
导致崩溃
最佳答案
- (NSMutableArray *) mutableFloobizwits {
NSMutableArray *array = [NSMutableArray array];
for (NSInteger i = 0; i < TheAnswerToTheUltimateQuestion; ++i) {
void(^MyBlock)(void) = ^{
NSLog(@"captured i: %ld", i);
};
MyBlock = [MyBlock copy]; //move the block from off the stack and onto the heap
[array addObject:[Floobizwit floobizwithWithBlock:MyBlock]];
[MyBlock release]; //the Floobizwit should've -retained the block, so we release it
}
return array;
}
关于iphone - iOS - 通过方法返回传递 NSMutableArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5146174/