UA-17470720-3

Jump to content


Photo
- - - - -

Tutorial - How to bind iTunes web service to show your app list?


  • Please log in to reply
8 replies to this topic

#1 devia

devia

    Jr. Member

  • STV 3.0 Pro
  • PipPip
  • 20 posts
Reputation: 8
Good

Posted 22 January 2013 - 07:05 PM

Hi guys. I'm learning STV now. STV web service binding is an great feature in STV 3.0 pro, i JUST implemented an demo that show you how to bind iTunes web service to list all of your apps. Share it with every STV guys. :)

- (void)demoWebServiceBinding
{
SCWebServiceDefinition *itunesDef = [SCWebServiceDefinition definitionWithBaseURL:@"https://itunes.apple.com/"
fetchObjectsAPI:@"lookup"
resultsKeyName:@"results"
resultsDictionaryKeyNamesString:@"trackName;sellerName;releaseDate"];
[itunesDef.fetchObjectsParameters setValue:@"504xxx87" forKey:@"id"]; // Your Team ID
[itunesDef.fetchObjectsParameters setValue:@"us" forKey:@"country"]; // Country
[itunesDef.fetchObjectsParameters setValue:@"software" forKey:@"entity"]; // Category is software

SCPropertyDefinition *textPropertyDef = [itunesDef propertyDefinitionWithName:@"trackName"];
textPropertyDef.title = @"App Name";
textPropertyDef.type = SCPropertyTypeTextView;
SCPropertyDefinition *userPropertyDef = [itunesDef propertyDefinitionWithName:@"sellerName"];
userPropertyDef.title = @"Seller Name";
userPropertyDef.type = SCPropertyTypeLabel;
SCPropertyDefinition *tweetedAtPropertyDef = [itunesDef propertyDefinitionWithName:@"releaseDate"];
tweetedAtPropertyDef.title = @"Release At";
tweetedAtPropertyDef.type = SCPropertyTypeLabel;

// Add tweets section
SCArrayOfObjectsSection *itunesSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil webServiceDefinition:itunesDef];
itunesSection.itemsAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
itunesSection.allowAddingItems = NO;
itunesSection.allowDeletingItems = NO;
itunesSection.allowEditDetailView = NO;
itunesSection.allowMovingItems = NO;

itunesSection.sectionActions.didFetchItemsFromStore = ^(SCArrayOfItemsSection *itemsSection, NSMutableArray *items)
{
// Add a button cell at the end of the items list
if (items.count > 1)
[items removeObjectAtIndex:0]; // First entry is a fake so we delete it from data store!
};

itunesSection.cellActions.didSelect = ^(SCTableViewCell *cell, NSIndexPath *indexPath) {
// Get app link and open it in AppStore
id boundObject = cell.boundObject;
if ([boundObject isKindOfClass:[NSDictionary class]]) {
NSString *applink = [(NSDictionary *)boundObject objectForKey:@"trackViewUrl"];
if (applink) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:applink]];
}
}
};

itunesSection.sectionActions.cellForRowAtIndexPath = ^SCCustomCell*(SCArrayOfItemsSection *itemsSection, NSIndexPath *indexPath){

SCCustomCell *cell = [SCCustomCell cellWithText:nil
objectBindingsString:@"1:artworkUrl60;2:trackName;3:sellerName" // 1,2,3 is views' tag
nibName:@"TweetCell"];

return cell;
};

[self.tableViewModel addSection:itunesSection];

// Enable pull-to-refresh
self.tableViewModel.enablePullToRefresh = YES;
}

Edited by devia, 22 January 2013 - 07:07 PM.

  • Tarek, cometlinear and wizgod like this

#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 23 January 2013 - 02:12 PM

Awesome work! Thanks a lot for sharing :)

#3 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 24 January 2013 - 02:46 AM

Hi devia,

WOW! That's great! Thanks very much.

It only shows 2 of my 3 App Store apps for some reason, I'll have to investigate further what's going on.
Cheers,

Dave

www.dgapps.ie

#4 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 24 January 2013 - 02:56 AM

Ah, a quick google found this:


http://www.apple.com...search-api.html

And changing from this:

https://itunes.apple...ware&country=ie

to this:

https://itunes.apple...ware&country=us

get's all three apps. (Note country=us and not country=ie)

And changing back to @"us" instead of @"ie" in devia's code displays all three apps in the table.


Great!

This wasn't something I had considered doing, bit it will now come in VERY useful!

Thank you very much!
  • Tarek and wizgod like this
Cheers,

Dave

www.dgapps.ie

#5 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 24 January 2013 - 09:59 AM

And changing from this:

https://itunes.apple...ware&country=ie

to this:

https://itunes.apple...ware&country=us


get's all three apps. (Note country=us and not country=ie)


Awesome, thanks Dave!!

#6 devia

devia

    Jr. Member

  • STV 3.0 Pro
  • PipPip
  • 20 posts
Reputation: 8
Good

Posted 29 January 2013 - 04:18 AM

Ah, a quick google found this:


http://www.apple.com...search-api.html

And changing from this:

https://itunes.apple...ware&country=ie

to this:

https://itunes.apple...ware&country=us

get's all three apps. (Note country=us and not country=ie)

And changing back to @"us" instead of @"ie" in devia's code displays all three apps in the table.


Great!

This wasn't something I had considered doing, bit it will now come in VERY useful!

Thank you very much!


Great. Thanks@

#7 cometlinear

cometlinear

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 55 posts
  • LocationCalifornia
Reputation: 10
Good

Posted 04 February 2013 - 11:11 AM

Apologies for the dumb question, but would you mind telling us exactly where in the project you are implementing this code?

#8 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 539 posts
  • LocationIreland
Reputation: 134
Popular

Posted 06 February 2013 - 02:16 AM

Hi cometlinear,

It looked liked devia was working from the Twitter client example from the PDF book, especially as there's a reference to the TweetCell XIB in the code above.

I replaced that examples viewDidLoad: with the above code and it all just worked.

HTH
  • cometlinear likes this
Cheers,

Dave

www.dgapps.ie

#9 cometlinear

cometlinear

    Experienced Member

  • STV 3.0 Pro
  • PipPipPipPip
  • 55 posts
  • LocationCalifornia
Reputation: 10
Good

Posted 06 February 2013 - 04:54 PM

Thanks Dave!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users