ithlony / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

Intro web pages have incorrect sample code #598

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This web page:
      https://developers.google.com/cast/docs/ios_sender

Has the following sample code
     1. self.deviceScanner = [[GCKDeviceScanner alloc] init];
     2.  GCKFilterCriteria *filterCriteria = [[GCKFilterCriteria alloc] init];
     3.  filterCriteria = [GCKFilterCriteria criteriaForAvailableApplicationWithID:@"YOUR_APP_ID_HERE"];
     4.  self.deviceScanner.filterCriteria = filterCriteria;
     5.  [self.deviceScanner addListener:self];
     6.  [self.deviceScanner startScan];

There are two problems with the sample above.
     issue#1:   Line 1 uses a deprecated API.  (It probably should be initWithFilterCriteria:)
     issue#2:   Line 3 overwrites a variable that was instantiated just one line before.

Fix:  I believe the correct (and far less confusing) code should look more 
like. 
      1.  GCKFilterCriteria *filterCriteria = GCKFilterCriteria criteriaForAvailableApplicationWithID:@"YOUR_APP_ID_HERE"];
      2.  self.deviceScanner = [[GCKDeviceScanner alloc] initWithFilterCriteria:filterCriteria];
      3.  [self.deviceScanner addListener:self];
      4.  [self.deviceScanner startScan];

Original issue reported on code.google.com by g...@clasp.tv on 17 Jun 2015 at 10:16

GoogleCodeExporter commented 8 years ago
Thanks for bringing this up. We'll update the documentation.

Original comment by jonathan...@google.com on 18 Jun 2015 at 8:57

GoogleCodeExporter commented 8 years ago
Documentation has been updated.

Original comment by jonathan...@google.com on 24 Jun 2015 at 9:58