5

Google Data APIs Objective-C Client Library을 구축했으며 내 응용 프로그램 (GTMOAuth2 포함)을 연결하고 작동하게하고 데이터를 다시 가져올 수 있습니다. Provisioning API (여전히 XML 만 사용)으로 작업해야하므로 내 응용 프로그램 내에서 필요한 추가 기능을 구축하고 있습니다. 나는 마침내이 모든 것들이 어떻게 작동하는지 알았고, 나는 매우에 가까운 사용자 정의 요소를 읽지 만, 나는 뭔가 빠져있다.Google Data Objective-C 클라이언트 라이브러리에서 GDataEntryBase를 하위 클래스로 만들 때 "인식 할 수없는 선택기"오류가 발생하는 이유는 무엇입니까?

GDataServiceGoogle, GDataEntryBaseGDataFeedBase을 서브 클래스 화했으며 정확한 데이터를 다시 얻고 있습니다. 간단한 & 직선 요소 유형으로 시작합니다 : quota. [사용자 피드에서 할당량 요소는 다음과 같습니다 : 그래서

<apps:quota limit="2048"/> 

, 나는 다음과 같은 값 구조에 추가했습니다

@interface GDataQuotaProperty : GDataValueConstruct <GDataExtension> 
+ (NSString *)extensionElementURI; 
+ (NSString *)extensionElementPrefix; 
+ (NSString *)extensionElementLocalName; 
@end 

@implementation GDataQuotaProperty 
+ (NSString *)extensionElementURI  { return kGDataNamespaceGApps; } 
+ (NSString *)extensionElementPrefix { return kGDataNamespaceGAppsPrefix; } 
+ (NSString *)extensionElementLocalName { return @"quota"; } 
@end 

을 그리고 난 내 GDataEntryBase 서브 클래스에 다음과 같은 방법을 추가했습니다 : 로 구현

- (GDataQuotaProperty *)quota; 
- (void)setQuota:(GDataQuotaProperty *)val; 

은 다음과 같습니다

- (GDataQuotaProperty *)quota { 
    return [self objectForExtensionClass:[GDataQuotaProperty class]]; 
} 

- (void)setQuota:(GDataQuotaProperty *)val { 
    [self setObject:val forExtensionClass:[GDataQuotaProperty class]]; 
} 
그러나

- (void)addExtensionDeclarations { 
    [super addExtensionDeclarations]; 

    Class entryClass = [self class]; 

    // User extensions 
    [self addExtensionDeclarationForParentClass:entryClass 
            childClasses:[GDataQuotaProperty class], nil]; 
} 

내가하려고 할 때 :3210 documented in the comments in GDataObject.h으로

(내가 GDataServiceGoogleCalendar, GDataEntryCalendar 떨어져 작업 있었고, 참조 구현으로 GDataFeedCalendar) 다음과 같이 내 GDataBaseEntry 서브 클래스에서 나는 addExtensionDeclarations을 구현했습니다 내 콜백에서 다음과 같이 quota 메소드를 호출합니다 :

:

GDataTextConstruct *titleTextConstruct = [user title]; 
NSString *title = [titleTextConstruct stringValue]; 
GDataQuotaProperty *quotaConstruct = [user quota]; 
NSString *quota = [quotaConstruct stringValue]; 

나는 예외이 오류

2012-11-19 12:42:22.667 Google Apps Open Directory Sync[47679:903] -[GDataEntryBase quota]: unrecognized selector sent to instance 0x2836d0 

위의 예에서 나는 사용자 이름 (요소의 title)을 오류없이 올바르게 반환합니다. 또한 user 객체는 실제로 내 GDataEntryBase 하위 클래스의 유형이며 GDataEntryBase 자체가 아니라 (디버거에서 확인 됨) 내 GDataFeedBase 하위 클래스의 classForEntries 메서드는 내 하위 클래스 GDataEntryBase 클래스를 올바르게 반환합니다. 은 실제로이 올바른 클래스 여야합니다. 내 GDataEntryBase 하위 클래스의 quota 메서드에 중단 점이 없으므로 절대로 여기에서 누락 되었습니까?

언급 한 바와 같이, 나는 달력에 대한 서비스/공급/입력 구현 (특히 accessLevel & color 요소 및 방법)과 비교 봤는데 저는 누락 된 것을 바로보고 있지 않다.

도움을 주셔서 미리 감사드립니다.

- (Class)classForEntries { 
    return [GDataEntryUser class]; 
} 

내가 같은 GDataFeedBase 하위 클래스에서 standardKindAttributeValue의 구현을 놓쳤다 다음과 같이 내가 내 GDataFeedBase 서브 클래스에 classForEntries 방법을 구현했고 올바르게에서 내 GDataEntryBase 서브 클래스의 클래스를 반환 동안

+2

+1 이것은 꽤 잘 형성되고 상세한 질문이기 때문에 라이브러리는 기본 "GDataQuotaProperty"클래스를 찾고 하위 클래스에 대해 아무것도 모르기 때문에 첫 번째 생각입니다. 이것은 카테고리로 달성 할 수있는 일일 수도 있습니다. 나는 이것을 조금 더 생각해야 할 것이다. –

+0

감사합니다. 기본 클래스가 하위 클래스를 찾을 수 없다는 것에 동의합니다. 나는 구글 데이터 오브젝티브 -C 라이브러리를 사용하는 사람들과 링크 문제를 수정함으로써 해결 된 유사한 "인식 할 수없는 선택자"에러를 얻는 몇 가지 다른 예를 발견했다. 그래서 나는 이것을 고려했다 (GDataObject.h는 " 확장의 진정한 목적은 엘리먼트가 알지 못하는 아이들을 포함 할 수있게하는 것이다. "). – morgant

+0

나는 몇 가지 명확한 설명으로 질문을 갱신했다. '[user quota]'예제 호출에서'user' 변수와 관련하여. – morgant

답변

1

적절한 카테고리 스키마 URL (Google 프로비저닝 API 사용자 피드의 경우 'http://schemas.google.com/apps/2006#user')을 반환해야합니다.

+ (NSString *)standardKindAttributeValue { 
    return @"http://schemas.google.com/apps/2006#user"; 
} 

일단 addExtensionDeclarationsclassForEntries, 그리고 standardKindAttributeValue 모든 GDataEntryBase 제대로 내 서브 클래스의 개체를 사용하는 것을 확인할 수 있었다 올바르게 구현되었다 : 그래서, 나는 (내가 실제로 상수를 사용하지만) 다음과 같이 구현 피드와 그래서 내 선택자는 인정 받았다.

올바른 방향으로 나를 가리키는 Google의 Greg Robbins에게 많은 감사를드립니다. in this thread on the Google Data APIs Objective-C Client Libraries discussion group.