Playlist Generator  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
Playlist2/AddToPlaylistViewController.m
Go to the documentation of this file.
00001 //
00002 //  AddToPlaylistViewController.m
00003 //  Playlist2
00004 //
00005 //  Created by Max Woolf on 30/01/2012.
00006 //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
00007 //
00008 
00009 #import "AddToPlaylistViewController.h"
00010 #import "CocoaLibSpotify.h"
00011 
00012 @implementation AddToPlaylistViewController
00013 
00014 -(id)initWithURI:(NSString *)theuri
00015 {
00016     uri = theuri;
00017     return [super init];
00018 }
00019 
00020 - (void)didReceiveMemoryWarning
00021 {
00022     // Releases the view if it doesn't have a superview.
00023     [super didReceiveMemoryWarning];
00024     
00025     // Release any cached data, images, etc that aren't in use.
00026 }
00027 #pragma mark - Table Delegate Methods
00028 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
00029 {
00030     return 1;
00031 }
00032 
00033 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
00034 {
00035     return [playlistNames count];
00036 }
00037 
00038 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
00039 
00040     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"playlistIdentifier"];
00041     if (cell == nil) {
00042         cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"playlistIdentifier"];
00043     }
00044     
00045     cell.textLabel.text = [playlistNames objectAtIndex:indexPath.row];
00046     return cell;
00047 }
00048 
00049 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
00050 {
00051     [tableView deselectRowAtIndexPath:indexPath animated:YES];
00052 }
00053 
00054 -(void)populateArray
00055 {
00056     SPPlaylistContainer *container = [SPSession sharedSession].userPlaylists;
00057     NSMutableArray *playlists = container.playlists;
00058     playlistNames = [[NSMutableArray alloc] init];
00059     for(int x = 0; x < [playlists count]; x++)
00060     {
00061         SPPlaylist *currentPlaylist = [playlists objectAtIndex:x];
00062         if([currentPlaylist.owner isEqual:[SPSession sharedSession].user])
00063         {
00064             NSLog(@"%@", [currentPlaylist spotifyURL]);
00065             //[playlistNames addObject:[currentPlaylist name]];
00066         }
00067     }
00068 }
00069 
00070 #pragma mark - View lifecycle
00071 
00072 - (void)viewDidLoad
00073 {
00074     NSLog(@"%@", uri);
00075     [self populateArray];
00076     [super viewDidLoad];
00077     // Do any additional setup after loading the view from its nib.
00078 }
00079 
00080 - (void)viewDidUnload
00081 {
00082     [super viewDidUnload];
00083     // Release any retained subviews of the main view.
00084     // e.g. self.myOutlet = nil;
00085 }
00086 
00087 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
00088 {
00089     // Return YES for supported orientations
00090     return (interfaceOrientation == UIInterfaceOrientationPortrait);
00091 }
00092 
00093 @end