diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings new file mode 100644 index 0000000..4f86e37 --- /dev/null +++ b/en.lproj/Localizable.strings @@ -0,0 +1,24 @@ +/* + Localizable.strings + iTunesSearch + + Created by Bruno Omella Mainieri on 3/15/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ + +"Buscar"= "Search"; + +"Filmes"= "Movies"; +"Filme"= "Movie"; +"Musica"= "Music"; +"Musicas"= "Music"; +"Podcast"="Podcast"; +"Podcasts"="Podcasts"; +"Ebook"="Ebook"; +"Ebooks"="Ebooks"; + +"Preço: %@"="Price: %@"; + +"Busca invalida!"="Invalid Query!"; + + diff --git a/fr.lproj/Localizable.strings b/fr.lproj/Localizable.strings new file mode 100644 index 0000000..ac0f5f1 --- /dev/null +++ b/fr.lproj/Localizable.strings @@ -0,0 +1,22 @@ +/* + Localizable.strings + iTunesSearch + + Created by Bruno Omella Mainieri on 3/15/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ + +"Buscar"= "Rechercher"; + +"Filmes"= "Films"; +"Filme"= "Film"; +"Musica"= "Musique"; +"Musicas"= "Musique"; +"Podcast"="Podcast"; +"Podcasts"="Podcasts"; +"Ebook"="Ebook"; +"Ebooks"="Ebooks"; + +"Preço: %@"="Prix: %@"; + +"Busca invalida!"="Recherche non valide!"; \ No newline at end of file diff --git a/iTunesSearch.xcodeproj/project.pbxproj b/iTunesSearch.xcodeproj/project.pbxproj index 79e06d7..d8fb296 100644 --- a/iTunesSearch.xcodeproj/project.pbxproj +++ b/iTunesSearch.xcodeproj/project.pbxproj @@ -7,13 +7,23 @@ objects = { /* Begin PBXBuildFile section */ + 1513F4AB1AB347240015FBAD /* MediaIcons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1513F4AA1AB347240015FBAD /* MediaIcons.xcassets */; }; + 1531ED6B1AB0C54700CA5FCD /* MusicTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1531ED691AB0C54700CA5FCD /* MusicTableViewCell.m */; }; + 1531ED6C1AB0C54700CA5FCD /* MusicTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1531ED6A1AB0C54700CA5FCD /* MusicTableViewCell.xib */; }; + 1531ED6F1AB0C95E00CA5FCD /* Midia.m in Sources */ = {isa = PBXBuildFile; fileRef = 1531ED6E1AB0C95E00CA5FCD /* Midia.m */; }; + 1531ED741AB0D4A500CA5FCD /* DetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1531ED721AB0D4A500CA5FCD /* DetailsViewController.m */; }; + 1531ED751AB0D4A500CA5FCD /* DetailsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1531ED731AB0D4A500CA5FCD /* DetailsViewController.xib */; }; + 155A5F3B1AAF8884000ED33A /* Musica.m in Sources */ = {isa = PBXBuildFile; fileRef = 155A5F3A1AAF8884000ED33A /* Musica.m */; }; + 155A5F3E1AAF8896000ED33A /* Podcast.m in Sources */ = {isa = PBXBuildFile; fileRef = 155A5F3D1AAF8896000ED33A /* Podcast.m */; }; + 155A5F411AAF88A2000ED33A /* Ebook.m in Sources */ = {isa = PBXBuildFile; fileRef = 155A5F401AAF88A2000ED33A /* Ebook.m */; }; + 15B09B041AB6076200DFE6F2 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15B09B061AB6076200DFE6F2 /* Localizable.strings */; }; + 15B2BE131AB1F7EC00E1C40D /* TableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15B2BE151AB1F7EC00E1C40D /* TableView.xib */; }; 92C21CB61AAE757A0052ABE6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CB51AAE757A0052ABE6 /* main.m */; }; 92C21CB91AAE757A0052ABE6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CB81AAE757A0052ABE6 /* AppDelegate.m */; }; 92C21CBC1AAE757A0052ABE6 /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CBB1AAE757A0052ABE6 /* TableViewController.m */; }; 92C21CC11AAE757A0052ABE6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92C21CC01AAE757A0052ABE6 /* Images.xcassets */; }; 92C21CD01AAE757A0052ABE6 /* iTunesSearchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CCF1AAE757A0052ABE6 /* iTunesSearchTests.m */; }; 92C21CDB1AAE75B30052ABE6 /* iTunesManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */; }; - 92C21CDD1AAE75DC0052ABE6 /* TableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */; }; 92C21CE11AAE76930052ABE6 /* TableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CDF1AAE76930052ABE6 /* TableViewCell.m */; }; 92C21CE21AAE76930052ABE6 /* TableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 92C21CE01AAE76930052ABE6 /* TableViewCell.xib */; }; 92C21CE81AAE858E0052ABE6 /* Filme.m in Sources */ = {isa = PBXBuildFile; fileRef = 92C21CE71AAE858E0052ABE6 /* Filme.m */; }; @@ -30,6 +40,25 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 1513F4AA1AB347240015FBAD /* MediaIcons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = MediaIcons.xcassets; sourceTree = ""; }; + 1531ED681AB0C54700CA5FCD /* MusicTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MusicTableViewCell.h; sourceTree = ""; }; + 1531ED691AB0C54700CA5FCD /* MusicTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MusicTableViewCell.m; sourceTree = ""; }; + 1531ED6A1AB0C54700CA5FCD /* MusicTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MusicTableViewCell.xib; sourceTree = ""; }; + 1531ED6D1AB0C95E00CA5FCD /* Midia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Midia.h; path = Entidades/Midia.h; sourceTree = ""; }; + 1531ED6E1AB0C95E00CA5FCD /* Midia.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Midia.m; path = Entidades/Midia.m; sourceTree = ""; }; + 1531ED711AB0D4A500CA5FCD /* DetailsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailsViewController.h; sourceTree = ""; }; + 1531ED721AB0D4A500CA5FCD /* DetailsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailsViewController.m; sourceTree = ""; }; + 1531ED731AB0D4A500CA5FCD /* DetailsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DetailsViewController.xib; sourceTree = ""; }; + 155A5F391AAF8884000ED33A /* Musica.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Musica.h; path = Entidades/Musica.h; sourceTree = ""; }; + 155A5F3A1AAF8884000ED33A /* Musica.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Musica.m; path = Entidades/Musica.m; sourceTree = ""; }; + 155A5F3C1AAF8896000ED33A /* Podcast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Podcast.h; path = Entidades/Podcast.h; sourceTree = ""; }; + 155A5F3D1AAF8896000ED33A /* Podcast.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Podcast.m; path = Entidades/Podcast.m; sourceTree = ""; }; + 155A5F3F1AAF88A2000ED33A /* Ebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Ebook.h; path = Entidades/Ebook.h; sourceTree = ""; }; + 155A5F401AAF88A2000ED33A /* Ebook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Ebook.m; path = Entidades/Ebook.m; sourceTree = ""; }; + 15B09B051AB6076200DFE6F2 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/Localizable.strings; sourceTree = ""; }; + 15B09B071AB6077000DFE6F2 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; + 15B09B081AB6077000DFE6F2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 15B2BE141AB1F7EC00E1C40D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/TableView.xib; sourceTree = ""; }; 92C21CB01AAE757A0052ABE6 /* iTunesSearch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iTunesSearch.app; sourceTree = BUILT_PRODUCTS_DIR; }; 92C21CB41AAE757A0052ABE6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 92C21CB51AAE757A0052ABE6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -43,7 +72,6 @@ 92C21CCF1AAE757A0052ABE6 /* iTunesSearchTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iTunesSearchTests.m; sourceTree = ""; }; 92C21CD91AAE75B30052ABE6 /* iTunesManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTunesManager.h; sourceTree = ""; }; 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTunesManager.m; sourceTree = ""; }; - 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableView.xib; sourceTree = ""; }; 92C21CDE1AAE76930052ABE6 /* TableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewCell.h; sourceTree = ""; }; 92C21CDF1AAE76930052ABE6 /* TableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewCell.m; sourceTree = ""; }; 92C21CE01AAE76930052ABE6 /* TableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableViewCell.xib; sourceTree = ""; }; @@ -69,9 +97,20 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1531ED701AB0D47B00CA5FCD /* Detalhes */ = { + isa = PBXGroup; + children = ( + 1531ED711AB0D4A500CA5FCD /* DetailsViewController.h */, + 1531ED721AB0D4A500CA5FCD /* DetailsViewController.m */, + 1531ED731AB0D4A500CA5FCD /* DetailsViewController.xib */, + ); + name = Detalhes; + sourceTree = ""; + }; 92C21CA71AAE757A0052ABE6 = { isa = PBXGroup; children = ( + 15B09B061AB6076200DFE6F2 /* Localizable.strings */, 92C21CB21AAE757A0052ABE6 /* iTunesSearch */, 92C21CCC1AAE757A0052ABE6 /* iTunesSearchTests */, 92C21CB11AAE757A0052ABE6 /* Products */, @@ -90,16 +129,18 @@ 92C21CB21AAE757A0052ABE6 /* iTunesSearch */ = { isa = PBXGroup; children = ( + 1531ED701AB0D47B00CA5FCD /* Detalhes */, 92C21CE31AAE76AA0052ABE6 /* Celulas */, 92C21CE91AAE859A0052ABE6 /* Entidades */, 92C21CB71AAE757A0052ABE6 /* AppDelegate.h */, 92C21CB81AAE757A0052ABE6 /* AppDelegate.m */, 92C21CBA1AAE757A0052ABE6 /* TableViewController.h */, 92C21CBB1AAE757A0052ABE6 /* TableViewController.m */, - 92C21CDC1AAE75DC0052ABE6 /* TableView.xib */, + 15B2BE151AB1F7EC00E1C40D /* TableView.xib */, 92C21CD91AAE75B30052ABE6 /* iTunesManager.h */, 92C21CDA1AAE75B30052ABE6 /* iTunesManager.m */, 92C21CC01AAE757A0052ABE6 /* Images.xcassets */, + 1513F4AA1AB347240015FBAD /* MediaIcons.xcassets */, 92C21CB31AAE757A0052ABE6 /* Supporting Files */, ); path = iTunesSearch; @@ -137,6 +178,9 @@ 92C21CDE1AAE76930052ABE6 /* TableViewCell.h */, 92C21CDF1AAE76930052ABE6 /* TableViewCell.m */, 92C21CE01AAE76930052ABE6 /* TableViewCell.xib */, + 1531ED681AB0C54700CA5FCD /* MusicTableViewCell.h */, + 1531ED691AB0C54700CA5FCD /* MusicTableViewCell.m */, + 1531ED6A1AB0C54700CA5FCD /* MusicTableViewCell.xib */, ); name = Celulas; sourceTree = ""; @@ -146,6 +190,14 @@ children = ( 92C21CE61AAE858E0052ABE6 /* Filme.h */, 92C21CE71AAE858E0052ABE6 /* Filme.m */, + 155A5F391AAF8884000ED33A /* Musica.h */, + 155A5F3A1AAF8884000ED33A /* Musica.m */, + 155A5F3C1AAF8896000ED33A /* Podcast.h */, + 155A5F3D1AAF8896000ED33A /* Podcast.m */, + 155A5F3F1AAF88A2000ED33A /* Ebook.h */, + 155A5F401AAF88A2000ED33A /* Ebook.m */, + 1531ED6D1AB0C95E00CA5FCD /* Midia.h */, + 1531ED6E1AB0C95E00CA5FCD /* Midia.m */, ); name = Entidades; sourceTree = ""; @@ -211,8 +263,9 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( - en, Base, + fr, + en, ); mainGroup = 92C21CA71AAE757A0052ABE6; productRefGroup = 92C21CB11AAE757A0052ABE6 /* Products */; @@ -231,8 +284,12 @@ buildActionMask = 2147483647; files = ( 92C21CC11AAE757A0052ABE6 /* Images.xcassets in Resources */, + 1513F4AB1AB347240015FBAD /* MediaIcons.xcassets in Resources */, 92C21CE21AAE76930052ABE6 /* TableViewCell.xib in Resources */, - 92C21CDD1AAE75DC0052ABE6 /* TableView.xib in Resources */, + 15B09B041AB6076200DFE6F2 /* Localizable.strings in Resources */, + 1531ED751AB0D4A500CA5FCD /* DetailsViewController.xib in Resources */, + 15B2BE131AB1F7EC00E1C40D /* TableView.xib in Resources */, + 1531ED6C1AB0C54700CA5FCD /* MusicTableViewCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -250,11 +307,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 155A5F411AAF88A2000ED33A /* Ebook.m in Sources */, + 1531ED6B1AB0C54700CA5FCD /* MusicTableViewCell.m in Sources */, 92C21CBC1AAE757A0052ABE6 /* TableViewController.m in Sources */, + 1531ED741AB0D4A500CA5FCD /* DetailsViewController.m in Sources */, + 155A5F3B1AAF8884000ED33A /* Musica.m in Sources */, + 155A5F3E1AAF8896000ED33A /* Podcast.m in Sources */, 92C21CDB1AAE75B30052ABE6 /* iTunesManager.m in Sources */, 92C21CB91AAE757A0052ABE6 /* AppDelegate.m in Sources */, 92C21CE81AAE858E0052ABE6 /* Filme.m in Sources */, 92C21CE11AAE76930052ABE6 /* TableViewCell.m in Sources */, + 1531ED6F1AB0C95E00CA5FCD /* Midia.m in Sources */, 92C21CB61AAE757A0052ABE6 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -277,6 +340,27 @@ }; /* End PBXTargetDependency section */ +/* Begin PBXVariantGroup section */ + 15B09B061AB6076200DFE6F2 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 15B09B051AB6076200DFE6F2 /* pt */, + 15B09B071AB6077000DFE6F2 /* fr */, + 15B09B081AB6077000DFE6F2 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; + 15B2BE151AB1F7EC00E1C40D /* TableView.xib */ = { + isa = PBXVariantGroup; + children = ( + 15B2BE141AB1F7EC00E1C40D /* Base */, + ); + name = TableView.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + /* Begin XCBuildConfiguration section */ 92C21CD11AAE757A0052ABE6 /* Debug */ = { isa = XCBuildConfiguration; diff --git a/iTunesSearch/AppDelegate.m b/iTunesSearch/AppDelegate.m index d513fd8..fbf1600 100644 --- a/iTunesSearch/AppDelegate.m +++ b/iTunesSearch/AppDelegate.m @@ -8,7 +8,7 @@ #import "AppDelegate.h" -#warning Classe importada para uso no metodo de inicilizacao da App +//#warning Classe importada para uso no metodo de inicilizacao da App #import "TableViewController.h" @interface AppDelegate () @@ -20,15 +20,16 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { -#warning Necessário para inicializar a aplicacao sem storyboard +//#warning Necessário para inicializar a aplicacao sem storyboard self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; -#warning Adicionado codigo para iniciar com a interface do TableView -// TableViewController *tvc = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil]; +//#warning Adicionado codigo para iniciar com a interface do TableView + //TableViewController *tvc = [[TableViewController alloc] initWithNibName:@"TableView" bundle:nil]; TableViewController *tvc = [[TableViewController alloc] init]; - [self.window setRootViewController:tvc]; + UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:tvc]; + [self.window setRootViewController:nav]; [self.window makeKeyAndVisible]; return YES; } diff --git a/iTunesSearch/Base.lproj/TableView.xib b/iTunesSearch/Base.lproj/TableView.xib new file mode 100644 index 0000000..fcc88a2 --- /dev/null +++ b/iTunesSearch/Base.lproj/TableView.xib @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iTunesSearch/DetailsViewController.h b/iTunesSearch/DetailsViewController.h new file mode 100644 index 0000000..5fdbc13 --- /dev/null +++ b/iTunesSearch/DetailsViewController.h @@ -0,0 +1,26 @@ +// +// DetailsViewController.h +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Midia.h" +#import "Filme.h" +#import "Musica.h" +#import "Ebook.h" +#import "Podcast.h" + +@interface DetailsViewController : UIViewController + +@property (weak, nonatomic) IBOutlet UIImageView *imagem; +@property (weak, nonatomic) IBOutlet UILabel *nome; +@property (weak, nonatomic) IBOutlet UILabel *artista; +@property (weak, nonatomic) IBOutlet UILabel *tipo; +@property (weak, nonatomic) IBOutlet UILabel *preco; +@property (weak, nonatomic) Midia *midia; + + +@end diff --git a/iTunesSearch/DetailsViewController.m b/iTunesSearch/DetailsViewController.m new file mode 100644 index 0000000..ff79a14 --- /dev/null +++ b/iTunesSearch/DetailsViewController.m @@ -0,0 +1,63 @@ +// +// DetailsViewController.m +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "DetailsViewController.h" + +@interface DetailsViewController () + +@end + + +@implementation DetailsViewController + +@synthesize midia; + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + if([midia isMemberOfClass:[Filme class]]){ + self.navigationItem.title = NSLocalizedString(@"Filme",nil); + self.tipo.text = NSLocalizedString(@"Filme",nil); + } + if([midia isMemberOfClass:[Musica class]]){ + self.navigationItem.title = NSLocalizedString(@"Musica",nil); + self.tipo.text = NSLocalizedString(@"Musica",nil); + } + if([midia isMemberOfClass:[Podcast class]]){ + self.navigationItem.title = NSLocalizedString(@"Podcast",nil); + self.tipo.text = NSLocalizedString(@"Podcast",nil); + } + if([midia isMemberOfClass:[Ebook class]]){ + self.navigationItem.title = NSLocalizedString(@"Ebook",nil); + self.tipo.text = NSLocalizedString(@"Ebook",nil); + } + self.nome.text = midia.nome; + self.preco.text = [NSString stringWithFormat:NSLocalizedString(@"Preço: %@",nil),midia.preco]; + self.artista.text = midia.artista; + NSURL *url = [NSURL URLWithString:midia.urlGrande]; + NSData *imgData = [NSData dataWithContentsOfURL:url]; + UIImage *img = [UIImage imageWithData:imgData]; + self.imagem.image = img; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/iTunesSearch/DetailsViewController.xib b/iTunesSearch/DetailsViewController.xib new file mode 100644 index 0000000..e540cc8 --- /dev/null +++ b/iTunesSearch/DetailsViewController.xib @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iTunesSearch/Entidades/Ebook.h b/iTunesSearch/Entidades/Ebook.h new file mode 100644 index 0000000..1c290e6 --- /dev/null +++ b/iTunesSearch/Entidades/Ebook.h @@ -0,0 +1,18 @@ +// +// Ebook.h +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/10/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Midia.h" + +@interface Ebook : Midia + + +@property (nonatomic, strong) NSNumber *rating; + + +@end diff --git a/iTunesSearch/Entidades/Ebook.m b/iTunesSearch/Entidades/Ebook.m new file mode 100644 index 0000000..012ee40 --- /dev/null +++ b/iTunesSearch/Entidades/Ebook.m @@ -0,0 +1,13 @@ +// +// Ebook.m +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/10/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Ebook.h" + +@implementation Ebook + +@end diff --git a/iTunesSearch/Entidades/Filme.h b/iTunesSearch/Entidades/Filme.h index eb126dc..a35d7f4 100644 --- a/iTunesSearch/Entidades/Filme.h +++ b/iTunesSearch/Entidades/Filme.h @@ -7,12 +7,10 @@ // #import +#import "Midia.h" -@interface Filme : NSObject +@interface Filme : Midia -@property (nonatomic, strong) NSString *nome; -@property (nonatomic, strong) NSString *trackId; -@property (nonatomic, strong) NSString *artista; @property (nonatomic, strong) NSString *duracao; @property (nonatomic, strong) NSString *genero; @property (nonatomic, strong) NSString *pais; diff --git a/iTunesSearch/Entidades/Midia.h b/iTunesSearch/Entidades/Midia.h new file mode 100644 index 0000000..0f2793a --- /dev/null +++ b/iTunesSearch/Entidades/Midia.h @@ -0,0 +1,20 @@ +// +// Midia.h +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import + +@interface Midia : NSObject + +@property (nonatomic, strong) NSString *nome; +@property (nonatomic, strong) NSString *trackId; +@property (nonatomic, strong) NSString *artista; +@property (nonatomic, strong) NSNumber *preco; +@property (nonatomic, strong) NSString *urlImg; +@property (nonatomic, strong) NSString *urlGrande; + +@end diff --git a/iTunesSearch/Entidades/Midia.m b/iTunesSearch/Entidades/Midia.m new file mode 100644 index 0000000..7a3c578 --- /dev/null +++ b/iTunesSearch/Entidades/Midia.m @@ -0,0 +1,13 @@ +// +// Midia.m +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Midia.h" + +@implementation Midia + +@end diff --git a/iTunesSearch/Entidades/Musica.h b/iTunesSearch/Entidades/Musica.h new file mode 100644 index 0000000..ee92c2d --- /dev/null +++ b/iTunesSearch/Entidades/Musica.h @@ -0,0 +1,20 @@ +// +// Musica.h +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/10/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Midia.h" + +@interface Musica : Midia + +@property (nonatomic, strong) NSString *album; +//@property (nonatomic, strong) NSString *duracao; +//@property (nonatomic, strong) NSString *genero; +@property (nonatomic, strong) NSString *pais; + + +@end diff --git a/iTunesSearch/Entidades/Musica.m b/iTunesSearch/Entidades/Musica.m new file mode 100644 index 0000000..fe44e48 --- /dev/null +++ b/iTunesSearch/Entidades/Musica.m @@ -0,0 +1,13 @@ +// +// Musica.m +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/10/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Musica.h" + +@implementation Musica + +@end diff --git a/iTunesSearch/Entidades/Podcast.h b/iTunesSearch/Entidades/Podcast.h new file mode 100644 index 0000000..5767b45 --- /dev/null +++ b/iTunesSearch/Entidades/Podcast.h @@ -0,0 +1,17 @@ +// +// Podcast.h +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/10/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import +#import "Midia.h" + +@interface Podcast : Midia + +@property (nonatomic, strong) NSString *generoPrincipal; + + +@end diff --git a/iTunesSearch/Entidades/Podcast.m b/iTunesSearch/Entidades/Podcast.m new file mode 100644 index 0000000..cd7ffa5 --- /dev/null +++ b/iTunesSearch/Entidades/Podcast.m @@ -0,0 +1,13 @@ +// +// Podcast.m +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/10/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "Podcast.h" + +@implementation Podcast + +@end diff --git a/iTunesSearch/MediaIcons.xcassets/ebook.imageset/Contents.json b/iTunesSearch/MediaIcons.xcassets/ebook.imageset/Contents.json new file mode 100644 index 0000000..02de492 --- /dev/null +++ b/iTunesSearch/MediaIcons.xcassets/ebook.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "ebook.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iTunesSearch/MediaIcons.xcassets/ebook.imageset/ebook.png b/iTunesSearch/MediaIcons.xcassets/ebook.imageset/ebook.png new file mode 100644 index 0000000..236fdf0 Binary files /dev/null and b/iTunesSearch/MediaIcons.xcassets/ebook.imageset/ebook.png differ diff --git a/iTunesSearch/MediaIcons.xcassets/filme.imageset/Contents.json b/iTunesSearch/MediaIcons.xcassets/filme.imageset/Contents.json new file mode 100644 index 0000000..2398d4a --- /dev/null +++ b/iTunesSearch/MediaIcons.xcassets/filme.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "filme.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iTunesSearch/MediaIcons.xcassets/filme.imageset/filme.png b/iTunesSearch/MediaIcons.xcassets/filme.imageset/filme.png new file mode 100644 index 0000000..5c8be4e Binary files /dev/null and b/iTunesSearch/MediaIcons.xcassets/filme.imageset/filme.png differ diff --git a/iTunesSearch/MediaIcons.xcassets/music.imageset/Contents.json b/iTunesSearch/MediaIcons.xcassets/music.imageset/Contents.json new file mode 100644 index 0000000..2162f99 --- /dev/null +++ b/iTunesSearch/MediaIcons.xcassets/music.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "music.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iTunesSearch/MediaIcons.xcassets/music.imageset/music.png b/iTunesSearch/MediaIcons.xcassets/music.imageset/music.png new file mode 100644 index 0000000..d6db81d Binary files /dev/null and b/iTunesSearch/MediaIcons.xcassets/music.imageset/music.png differ diff --git a/iTunesSearch/MediaIcons.xcassets/podcast.imageset/Contents.json b/iTunesSearch/MediaIcons.xcassets/podcast.imageset/Contents.json new file mode 100644 index 0000000..fba013f --- /dev/null +++ b/iTunesSearch/MediaIcons.xcassets/podcast.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "podcast.png" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iTunesSearch/MediaIcons.xcassets/podcast.imageset/podcast.png b/iTunesSearch/MediaIcons.xcassets/podcast.imageset/podcast.png new file mode 100644 index 0000000..3156441 Binary files /dev/null and b/iTunesSearch/MediaIcons.xcassets/podcast.imageset/podcast.png differ diff --git a/iTunesSearch/MusicTableViewCell.h b/iTunesSearch/MusicTableViewCell.h new file mode 100644 index 0000000..23885fc --- /dev/null +++ b/iTunesSearch/MusicTableViewCell.h @@ -0,0 +1,19 @@ +// +// MusicTableViewCell.h +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import + +@interface MusicTableViewCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UILabel *nome; +@property (weak, nonatomic) IBOutlet UILabel *artista; +@property (weak, nonatomic) IBOutlet UILabel *album; +@property (weak, nonatomic) IBOutlet UILabel *tipo; +@property (weak, nonatomic) IBOutlet UILabel *preco; + +@end diff --git a/iTunesSearch/MusicTableViewCell.m b/iTunesSearch/MusicTableViewCell.m new file mode 100644 index 0000000..f1c8aae --- /dev/null +++ b/iTunesSearch/MusicTableViewCell.m @@ -0,0 +1,23 @@ +// +// MusicTableViewCell.m +// iTunesSearch +// +// Created by Bruno Omella Mainieri on 3/11/15. +// Copyright (c) 2015 joaquim. All rights reserved. +// + +#import "MusicTableViewCell.h" + +@implementation MusicTableViewCell + +- (void)awakeFromNib { + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/iTunesSearch/MusicTableViewCell.xib b/iTunesSearch/MusicTableViewCell.xib new file mode 100644 index 0000000..fa36e80 --- /dev/null +++ b/iTunesSearch/MusicTableViewCell.xib @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iTunesSearch/TableView.xib b/iTunesSearch/TableView.xib deleted file mode 100644 index 55f128c..0000000 --- a/iTunesSearch/TableView.xib +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iTunesSearch/TableViewCell.h b/iTunesSearch/TableViewCell.h index b630349..798e36c 100644 --- a/iTunesSearch/TableViewCell.h +++ b/iTunesSearch/TableViewCell.h @@ -12,6 +12,9 @@ @property (weak, nonatomic) IBOutlet UILabel *nome; @property (weak, nonatomic) IBOutlet UILabel *tipo; +@property (weak, nonatomic) IBOutlet UILabel *artista; +@property (weak, nonatomic) IBOutlet UILabel *preco; +@property (weak, nonatomic) IBOutlet UIImageView *imagem; @end diff --git a/iTunesSearch/TableViewCell.xib b/iTunesSearch/TableViewCell.xib index bf8bd3f..bcfc5ee 100644 --- a/iTunesSearch/TableViewCell.xib +++ b/iTunesSearch/TableViewCell.xib @@ -1,5 +1,5 @@ - + @@ -7,40 +7,90 @@ - - + + - - + + + - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/iTunesSearch/TableViewController.h b/iTunesSearch/TableViewController.h index 0cbb5c4..5b85e7b 100644 --- a/iTunesSearch/TableViewController.h +++ b/iTunesSearch/TableViewController.h @@ -11,7 +11,14 @@ @interface TableViewController : UIViewController + +@property (strong, nonatomic) IBOutlet UIView *view; +@property (strong, nonatomic) IBOutlet UITextField *busca; @property (strong, nonatomic) IBOutlet UITableView *tableview; +@property (weak, nonatomic) IBOutlet UIButton *botaoBusca; + +- (IBAction)buscar:(id)sender; + @end diff --git a/iTunesSearch/TableViewController.m b/iTunesSearch/TableViewController.m index f689980..adaa065 100644 --- a/iTunesSearch/TableViewController.m +++ b/iTunesSearch/TableViewController.m @@ -8,11 +8,18 @@ #import "TableViewController.h" #import "TableViewCell.h" +#import "MusicTableViewCell.h" #import "iTunesManager.h" #import "Entidades/Filme.h" +#import "Musica.h" +#import "Podcast.h" +#import "Ebook.h" +#import "DetailsViewController.h" @interface TableViewController () { NSArray *midias; + NSUserDefaults *useDef; + NSString *termo; } @end @@ -24,14 +31,31 @@ @implementation TableViewController - (void)viewDidLoad { [super viewDidLoad]; + self.navigationItem.title = @"iTunes Search"; + [self.botaoBusca setTitle:NSLocalizedString(@"Buscar", nil) forState:UIControlStateNormal]; + + useDef = [NSUserDefaults standardUserDefaults]; + [useDef synchronize]; + + [_tableview setDelegate: self]; + _tableview.dataSource = self; + UINib *nib = [UINib nibWithNibName:@"TableViewCell" bundle:nil]; [self.tableview registerNib:nib forCellReuseIdentifier:@"celulaPadrao"]; iTunesManager *itunes = [iTunesManager sharedInstance]; - midias = [itunes buscarMidias:@"Apple"]; +// if(useDef==nil){ +// termo = @"Apple"; +// } +// else{ +// termo = [[useDef valueForKey:@"busca"] stringByReplacingOccurrencesOfString:@" " withString:@"+"]; +// } + midias = [itunes buscarMidias:[useDef valueForKey:@"busca"]]; + +// _tableview.contentInset = UIEdgeInsetsMake(-64, 0, 0, 0); + -#warning Necessario para que a table view tenha um espaco em relacao ao topo, pois caso contrario o texto ficara atras da barra superior - self.tableview.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.tableview.bounds.size.width, 15.f)]; + } - (void)didReceiveMemoryWarning { @@ -42,27 +66,135 @@ - (void)didReceiveMemoryWarning { #pragma mark - Metodos do UITableViewDataSource -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; + return 4; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return [midias count]; + + return [[midias objectAtIndex:section] count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { TableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"celulaPadrao"]; - Filme *filme = [midias objectAtIndex:indexPath.row]; + NSArray *media = [[NSArray alloc]initWithArray:[midias objectAtIndex:indexPath.section]]; - [celula.nome setText:filme.nome]; - [celula.tipo setText:@"Filme"]; + if(indexPath.section==0){ + //TableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"celulaPadrao"]; + Filme *filme = [media objectAtIndex:[indexPath row]]; + [celula.nome setText:filme.nome]; + [celula.artista setText:filme.artista]; + [celula.tipo setText:NSLocalizedString(@"Filme",nil)]; + [celula.preco setText:[NSString stringWithFormat:NSLocalizedString(@"Preço: %@",nil),filme.preco]]; + NSURL *url = [NSURL URLWithString:filme.urlImg]; + NSData *imgData = [NSData dataWithContentsOfURL:url]; + UIImage *img = [UIImage imageWithData:imgData]; + [celula.imagem setImage:img]; + + } + if(indexPath.section==1){ + //MusicTableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"musicCell"]; + Musica *musica = [media objectAtIndex:[indexPath row]]; + [celula.nome setText:musica.nome]; + [celula.artista setText:musica.artista]; + [celula.tipo setText:NSLocalizedString(@"Musica",nil)]; + [celula.preco setText:[NSString stringWithFormat:NSLocalizedString(@"Preço: %@",nil),musica.preco]]; + NSURL *url = [NSURL URLWithString:musica.urlImg]; + NSData *imgData = [NSData dataWithContentsOfURL:url]; + UIImage *img = [UIImage imageWithData:imgData]; + [celula.imagem setImage:img]; + //return celula; + } + if(indexPath.section==2){ + //TableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"celulaPadrao"]; + Podcast *podcast = [media objectAtIndex:[indexPath row]]; + [celula.nome setText:podcast.nome]; + [celula.artista setText:podcast.artista]; + [celula.tipo setText:NSLocalizedString(@"Podcast",nil)]; + [celula.preco setText:[NSString stringWithFormat:NSLocalizedString(@"Preço: %@",nil),podcast.preco]]; + NSURL *url = [NSURL URLWithString:podcast.urlImg]; + NSData *imgData = [NSData dataWithContentsOfURL:url]; + UIImage *img = [UIImage imageWithData:imgData]; + [celula.imagem setImage:img]; + } + if(indexPath.section==3){ + //TableViewCell *celula = [self.tableview dequeueReusableCellWithIdentifier:@"celulaPadrao"]; + Ebook *ebook = [media objectAtIndex:[indexPath row]]; + [celula.nome setText:ebook.nome]; + [celula.artista setText:ebook.artista]; + [celula.tipo setText:NSLocalizedString(@"Ebook",nil)]; + [celula.preco setText:[NSString stringWithFormat:NSLocalizedString(@"Preço: %@",nil),ebook.preco]]; + NSURL *url = [NSURL URLWithString:ebook.urlImg]; + NSData *imgData = [NSData dataWithContentsOfURL:url]; + UIImage *img = [UIImage imageWithData:imgData]; + [celula.imagem setImage:img]; + } return celula; } +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + DetailsViewController *details = [[DetailsViewController alloc]init]; + [details setMidia:[[ midias objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]]; + [self.navigationController pushViewController:details animated:YES]; +} + -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 70; + return 80; } +- (IBAction)buscar:(id)sender { + iTunesManager *itunes = [iTunesManager sharedInstance]; + + NSError *erroRegex=nil; + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^[a-z]([a-z]| |\\+|\\(|\\)|'|\\^)*$" options:NSRegularExpressionCaseInsensitive error:&erroRegex]; + + termo = self.busca.text; + + if(![regex numberOfMatchesInString:termo options:0 range:NSMakeRange(0, termo.length)]){ + UIAlertView *termoInvalido = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Busca invalida!",nil) message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [termoInvalido show]; + return; + } + + midias =[itunes buscarMidias:[termo stringByReplacingOccurrencesOfString:@" " withString:@"+"]]; + //[self categorizaMidia]; + [self.tableview reloadData]; + [_busca resignFirstResponder]; + [useDef setObject:self.busca.text forKey:@"busca"]; + [useDef synchronize]; + self.busca.text = @""; +} + + +-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ + UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, -20, tableView.frame.size.width, 18)]; + UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 3, 16, 16)]; + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(25, 2, tableView.frame.size.width, 18)]; + [label setFont:[UIFont boldSystemFontOfSize:12]]; + if (section == 0){ + [label setText:NSLocalizedString(@"Filmes", nil)]; + imgView.image = [UIImage imageNamed:@"filme"]; + } + if (section == 1){ + [label setText:NSLocalizedString(@"Musicas", nil)]; + imgView.image = [UIImage imageNamed:@"music"]; + } + if (section == 2){ + [label setText:NSLocalizedString(@"Podcasts", nil)]; + imgView.image = [UIImage imageNamed:@"podcast"]; + } + if (section == 3){ + [label setText:NSLocalizedString(@"Ebooks", nil)]; + imgView.image = [UIImage imageNamed:@"ebook"]; + } + [header addSubview:label]; + [header addSubview:imgView]; + [header setBackgroundColor:[UIColor grayColor]]; + return header; +} + + + @end diff --git a/iTunesSearch/iTunesManager.m b/iTunesSearch/iTunesManager.m index e2babda..af2a602 100644 --- a/iTunesSearch/iTunesManager.m +++ b/iTunesSearch/iTunesManager.m @@ -8,6 +8,10 @@ #import "iTunesManager.h" #import "Entidades/Filme.h" +#import "Musica.h" +#import "Podcast.h" +#import "Ebook.h" +#import "Midia.h" @implementation iTunesManager @@ -33,34 +37,83 @@ - (NSArray *)buscarMidias:(NSString *)termo { if (!termo) { termo = @""; } - - NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=movie", termo]; + termo = [termo stringByReplacingOccurrencesOfString:@" " withString:@"+"]; + NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=all&limit=200", termo]; NSData *jsonData = [NSData dataWithContentsOfURL: [NSURL URLWithString:url]]; NSError *error; NSDictionary *resultado = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error]; + if (error) { NSLog(@"Não foi possível fazer a busca. ERRO: %@", error); return nil; } - NSArray *resultados = [resultado objectForKey:@"results"]; + NSMutableArray *resultados = [resultado objectForKey:@"results"]; + NSMutableArray *midias = [[NSMutableArray alloc]init]; NSMutableArray *filmes = [[NSMutableArray alloc] init]; + NSMutableArray *musicas = [[NSMutableArray alloc] init]; + NSMutableArray *podcasts = [[NSMutableArray alloc] init]; + NSMutableArray *ebooks = [[NSMutableArray alloc] init]; + + void(^setMidia)(Midia*,NSDictionary*)=^(Midia *aux, NSDictionary *item){ + [aux setNome:[item objectForKey:@"trackName"]]; + [aux setTrackId:[item objectForKey:@"trackId"]]; + [aux setArtista:[item objectForKey:@"artistName"]]; + [aux setPreco:[item objectForKey:@"trackPrice"]]; + [aux setUrlImg:[item objectForKey:@"artworkUrl60"]]; + [aux setUrlGrande:[item objectForKey:@"artworkUrl100"]]; + + }; for (NSDictionary *item in resultados) { - Filme *filme = [[Filme alloc] init]; - [filme setNome:[item objectForKey:@"trackName"]]; - [filme setTrackId:[item objectForKey:@"trackId"]]; - [filme setArtista:[item objectForKey:@"artistName"]]; - [filme setDuracao:[item objectForKey:@"trackTimeMillis"]]; - [filme setGenero:[item objectForKey:@"primaryGenreName"]]; - [filme setPais:[item objectForKey:@"country"]]; - [filmes addObject:filme]; + + //FILME + if([[item objectForKey:@"kind"] isEqualToString:@"feature-movie"]){ + Filme *filme = [[Filme alloc]init]; + setMidia(filme, item); + [filme setDuracao:[item objectForKey:@"trackTimeMillis"]]; + [filme setGenero:[item objectForKey:@"primaryGenreName"]]; + [filme setPais:[item objectForKey:@"country"]]; + [filmes addObject:filme]; + } + + //MUSICA + if([[item objectForKey:@"kind"] isEqualToString:@"song"]){ + Musica *musica = [[Musica alloc]init]; + setMidia(musica, item); + [musica setAlbum:[item objectForKey:@"collectionName"]]; + [musica setPais:[item objectForKey:@"country"]]; + [musicas addObject:musica]; + } + + //EBOOK + if([[item objectForKey:@"kind"] isEqualToString:@"ebook"]){ + Ebook *ebook = [[Ebook alloc]init]; + setMidia(ebook, item); + [ebook setRating:[item objectForKey:@"averageUserRating"]]; + [ebook setPreco:[item objectForKey:@"price"]]; + [ebooks addObject:ebook]; + } + + //PODCAST + if([[item objectForKey:@"kind"] isEqualToString:@"podcast"]){ + Podcast *podcast = [[Podcast alloc]init]; + setMidia(podcast,item); + [podcast setGeneroPrincipal:[item objectForKey:@"primaryGenreName"]]; + [podcasts addObject:podcast]; + } + } - return filmes; + [midias addObject:filmes]; + [midias addObject:musicas]; + [midias addObject:ebooks]; + [midias addObject:podcasts]; + + return midias; } diff --git a/pt.lproj/Localizable.strings b/pt.lproj/Localizable.strings new file mode 100644 index 0000000..22489cf --- /dev/null +++ b/pt.lproj/Localizable.strings @@ -0,0 +1,22 @@ +/* + Localizable.strings + iTunesSearch + + Created by Bruno Omella Mainieri on 3/15/15. + Copyright (c) 2015 joaquim. All rights reserved. +*/ + +"Buscar"= "Buscar"; + +"Filmes"= "Filmes"; +"Filme"= "Filme"; +"Musica"= "Musica"; +"Musicas"= "Musicas"; +"Podcast"="Podcast"; +"Podcasts"="Podcasts"; +"Ebook"="Ebook"; +"Ebooks"="Ebooks"; + +"Preço: %@"="Preço: %@"; + +"Busca invalida!"="Busca invalida!"; \ No newline at end of file