메서드에 대한 포인터에 포인터를 전달하려고하는데 분명히 ARC는 내가하는 일에 몇 가지 문제가 있습니다. 여기에 두 가지 방법 :자동 참조 계산 문제 : 씁니다 백 아웃을위한 __autoreleasing 매개 변수에 로컬이 아닌 개체의 주소 전달
[self SHL_initPersonPropertyNamesWithArray:&propertyNames] : NULL;
메서드에 대한 포인터에 포인터를 전달하려고하는데 분명히 ARC는 내가하는 일에 몇 가지 문제가 있습니다. 여기에 두 가지 방법 :자동 참조 계산 문제 : 씁니다 백 아웃을위한 __autoreleasing 매개 변수에 로컬이 아닌 개체의 주소 전달
[self SHL_initPersonPropertyNamesWithArray:&propertyNames] : NULL;
__strong 저장 규정은이 경우에 필요한 다음 명령은 표시 줄에
Automatic Reference Counting Issue: Passing address of non-local object to __autoreleasing parameter for write-back
: 나는 다음과 같은 오류가 발생
+ (NSString *)personPropertyNameForIndex:(kSHLPersonDetailsTableRowIndex)index
{
static NSArray *propertyNames = nil;
(nil == propertyNames) ?
[self SHL_initPersonPropertyNamesWithArray:&propertyNames] : NULL;
}
+ (void)SHL_initPersonPropertyNamesWithArray:(NSArray **)theArray
{
*theArray = [[NSArray alloc]
initWithObjects:@"name", @"email", @"birthdate", @"phone", nil];
}
.
+ (void)SHL_initPersonPropertyNamesWithArray:(NSArray * __strong *)theArray
그러나이 코드는 Basic Memory Management Rules을 따르지 않습니다.
You own any object you create
You create an object using a method whose name begins with “alloc”, “new”, “copy”, or “mutableCopy” (for example, alloc, newObject, or mutableCopy).
어떤 이유에서 이것을 수행 하시겠습니까?
글쎄,이 메소드가 호출 될 때마다 조건부 IF를 사용하는 대신, 세 번째 연산에 이어지는 초기화 함수를 사용하지만, C가 아닌 Objective-C 환경에서 익숙한 것을 사용하는 것이 더 낫다. – Rami
[https://stackoverflow.com/questions/8814718/handling-pointer-to-pointer-ownership-issues-in-arc?answertab=active#tab-top]도 확인하십시오. doubt – tharinduNA