samjee / google-api-objectivec-client

Automatically exported from code.google.com/p/google-api-objectivec-client
0 stars 0 forks source link

unexpected behavior of GTLQuery as <GTLQueryProtocol> because of typecasting #84

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After revision 
r426 'Add testBlock support to GTLService and GTLQuery'
It has some unstable and unexpected behavior

for example in GTLService.h.518: 

---
  id<GTLQueryProtocol> originalQuery_; 

---
and in GTLService.m:493

---
  GTLQuery *originalQuery = (GTLQuery *)ticket.originalQuery; 
  if (originalQuery == nil) {
    originalQuery = (GTLQuery *)query;
    ticket.originalQuery = originalQuery;
  }

  GTLQueryTestBlock testBlock = originalQuery.testBlock;

---

So originalQuery may have no property .testBlock and this may cause crash

I have my own class which implemented <GTLQueryProtocol>
and my class have no .testBlock
so i need to implement some methods to make it work

---
- (GTLQueryTestBlock)testBlock {
    return nil;
}

- (NSDictionary*)dataToPost {
    return nil;
}

---

====== 
summary:

All properties and methods of GTLQuery used in GTLService should be described 
in <GTLQueryProtocol> and marked ad @required

also this should remove all type castings lite this

---
  GTLQuery *originalQuery = (GTLQuery *)ticket.originalQuery;

---
to 

---
  id<GTLQueryProtocol> *originalQuery = ticket.originalQuery;

---

Original issue reported on code.google.com by serg.f...@gmail.com on 4 Mar 2015 at 2:59