Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting "unrecognized selector" errors when subclassing GDataEntryBase from Google Data Objective-C Client Library?
    text
    copied!<p>I've built the <a href="http://code.google.com/p/gdata-objectivec-client/" rel="nofollow">Google Data APIs Objective-C Client Library</a> and have it linking and working with my application (incl. GTMOAuth2) and can pull data back. I need to work with the <a href="https://developers.google.com/google-apps/provisioning/" rel="nofollow">Provisioning API</a> (still XML-only) so am building out the additions I need within my own application. I think I have finally figured out how all of this works and I'm <em>very</em> close to reading custom elements, but I'm missing something.</p> <p>I've subclassed <code>GDataServiceGoogle</code>, <code>GDataEntryBase</code>, and <code>GDataFeedBase</code> and am getting correct data back. I'm starting with a simple &amp; straightforward element type: <code>quota</code>. In the Users feed, the quota element looks like this:</p> <pre><code>&lt;apps:quota limit="2048"/&gt; </code></pre> <p>So, I've added the following value construct:</p> <pre><code>@interface GDataQuotaProperty : GDataValueConstruct &lt;GDataExtension&gt; + (NSString *)extensionElementURI; + (NSString *)extensionElementPrefix; + (NSString *)extensionElementLocalName; @end @implementation GDataQuotaProperty + (NSString *)extensionElementURI { return kGDataNamespaceGApps; } + (NSString *)extensionElementPrefix { return kGDataNamespaceGAppsPrefix; } + (NSString *)extensionElementLocalName { return @"quota"; } @end </code></pre> <p>And I've added the following methods to my <code>GDataEntryBase</code> subclass:</p> <pre><code>- (GDataQuotaProperty *)quota; - (void)setQuota:(GDataQuotaProperty *)val; </code></pre> <p>Implemented as follows:</p> <pre><code>- (GDataQuotaProperty *)quota { return [self objectForExtensionClass:[GDataQuotaProperty class]]; } - (void)setQuota:(GDataQuotaProperty *)val { [self setObject:val forExtensionClass:[GDataQuotaProperty class]]; } </code></pre> <p>As <a href="http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Source/BaseClasses/GDataObject.h" rel="nofollow">documented in the comments in <code>GDataObject.h</code></a> (and I've been working off of <code>GDataServiceGoogleCalendar</code>, <code>GDataEntryCalendar</code>, and <code>GDataFeedCalendar</code> as a reference implementation), in my <code>GDataBaseEntry</code> subclass I've implemented <code>addExtensionDeclarations</code> as follows:</p> <pre><code>- (void)addExtensionDeclarations { [super addExtensionDeclarations]; Class entryClass = [self class]; // User extensions [self addExtensionDeclarationForParentClass:entryClass childClasses:[GDataQuotaProperty class], nil]; } </code></pre> <p>However, when I try to call the <code>quota</code> method as follows in my callback:</p> <pre><code>GDataTextConstruct *titleTextConstruct = [user title]; NSString *title = [titleTextConstruct stringValue]; GDataQuotaProperty *quotaConstruct = [user quota]; NSString *quota = [quotaConstruct stringValue]; </code></pre> <p>I get an exception and this error:</p> <pre><code>2012-11-19 12:42:22.667 Google Apps Open Directory Sync[47679:903] -[GDataEntryBase quota]: unrecognized selector sent to instance 0x2836d0 </code></pre> <p>In the above example I do get the user's name (the element's <code>title</code>) back correctly without error. Also, the <code>user</code> object is actually of the type of my <code>GDataEntryBase</code> subclass, not <code>GDataEntryBase</code> itself (verified in the debugger), plus the <code>classForEntries</code> method in my <code>GDataFeedBase</code> subclass correctly returns the class of my subclass of <code>GDataEntryBase</code>) so between the two of those it <em>really</em> has to be the correct class. I have a breakpoint on my <code>GDataEntryBase</code> subclass's <code>quota</code> method which is never being tripped, so what am I missing here?</p> <p>As mentioned, I've been comparing with the Service/Feed/Entry implementation for Calendar (specifically the <code>accessLevel</code> &amp; <code>color</code> elements and methods) and am just not seeing what I'm missing.</p> <p>Thanks in advance for any assistance you can provide.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload