정말 열거 형 몇 가지 "정수 32"특성 가진 NSManagedObject 하위 있습니다. 이 열거 형은이처럼 내 모델의 .H 파일에 정의되어 있습니다 :내 응용 프로그램에서 NSZombie를 찾았습니다 ... 이제 어떻게해야합니까?
typedef enum {
AMOwningCompanyACME,
AMOwningCompanyABC,
AMOwningCompanyOther
} AMOwningCompany;
내가,이 사용자 정의 개체의 각 속성의 값을 표시하는 테이블보기를 표시해야하는 각 열거에 대해 나는처럼 보이는 방법을 그래서 이 문자열 값 반환 : 내 테이블보기에서
-(NSArray*)stringsForAMOwningCompany
{
return [NSArray arrayWithObjects:@"ACME Co.", @"ABC Co.", @"Other", nil];
}
을 내 NSManagedObject
(사용 NSEntityDescription
의 attributesByName
의 속성을 반복하고 각 속성에 대해 나는 적절한 "stringsFor"메소드를 호출하는 도우미 메서드를 호출 해당 특정 속성에 대한 문자열을 반환하십시오.
-(NSArray*)getStringsArrayForAttribute:(NSString*)attributeName
{
SEL methodSelector = NSSelectorFromString([self methodNameForAttributeNamed:attributeName]);
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:[[AMProperty class] instanceMethodSignatureForSelector:methodSelector]];
[invocation setSelector:methodSelector];
[invocation setTarget:self.editingPole];
[invocation invoke];
NSArray* returnValue = nil;
[invocation getReturnValue:&returnValue];
return returnValue;
}
내 테이블보기의 cellForRowAtIndexPath
는 다음과 같습니다
...
NSString* itemName = self.tableData[indexPath.row];
NSAttributeDescription* desc = itemAttributes[itemName];
NSString* cellIdentifier = [self cellIdentifierForAttribute:desc]; // checks the attribute type and returns a different custom cell identifier accordingly
if ([cellIdentifier isEqualToString:@"enumCell"])
{
// dequeue cell, customize it
UITableViewCell* enumCell = ...
...
NSArray* stringValues = [[NSArray alloc] initWithArray:[self getStringArrayForAttribute:itemName]];
int currentValue = [(NSNumber*)[self.editingPole valueForKey:itemName] intValue];
enumCell.detailTextLabel.text = (NSString*)stringValues[currentValue];
return enumCell;
}
...
, 나는 NSInvocation
의 반환 배열에 충돌 점점 계속 :
-[__NSArrayI release]: message sent to deallocated instance 0x856a4b0
은 Using를 좀비 프로필러, 참조 :
저는 ARC를 사용하고 있습니다. 어떻게 디버깅 할 수 있습니까?
놀라움. 고맙습니다. Objective-C에서 메모리 관리를 완전히 이해하지 못했으며 ARC와 함께 걱정할 필요가 없다고 생각했습니다. 분명히 사실이 아닙니다;) – Shinigami
보통 당신은하지 않지만'void * '를 통해 객체를 전달하는 것은 미치광이 프린지와 같습니다. –