1
Swift에서 포인터에 대한 포인터를 어떻게 작성합니까? Objective-C에는 반복적으로 호출하여 반복 횟수를 추적 할 수있는 함수가 있었지만 Swift에서이를 달성하는 방법에 관해서는 난처한 편입니다. 이 게시물에 대한이 샘플을 절단하는 과정에서 Swift 함수의 포인터 매개 변수에 대한 포인터
NSNumber *recursionCount = [NSNumber numberWithInteger:-1];
[self doRecursion:&recursionCount];
- (void)doRecursion:(NSNumber **)recursionCount {
// I'm sure this is a terrible way to increment, but I have limited Objective-C experience
// and this worked, so I moved on after failing to find a decent var++ equivalent :-(
int addThis = (int)i + 1;
*recursionCount = [NSNumber numberWithInt:[*recursionCount intValue] + addThis];
[self doRecursion:recursionCount];
}
, 나는 끝없는 루프를 생성 결국했지만, 당신은 내가 각 재귀 값을 기억하고있어 방법에 대한 아이디어를 얻을.
누구나 스위프트에서이 작업을 수행하는 방법을 알고 있습니까? 감사.
감사합니다. 나는 inout 매개 변수에 대한 섹션을 놓치거나 건너 뛰었어야합니다. 나는 심지어 AutoreleasingUnsafeMutablePointer과 UnsafeMutablePointer 을 시도했지만 슬픔의 길을 인도했다. :) –