title: Using MPMediaPlaylistPropertyPlaylistAttributes and bitwise operators on NSInteger- Objective C (iPhone)
body: <p>and thanks in advance for you time.</p>
  
  <p>I am trying to filter out certain types of playlists for an iphone app (genius and On-the-go, specifically). the documentation says that the property attribute MPMediaPlaylistPropertyPlaylistAttributes will return the attributes associated with a playlist in the form of an NSNumber containing an NSInteger object. The documentation also lists these possible values for that property: </p>
  
  <p>e</p>
  
  <pre><code>num {
     MPMediaPlaylistAttributeNone    = 0,
     MPMediaPlaylistAttributeOnTheGo = (1 &lt;&lt; 0),
     MPMediaPlaylistAttributeSmart   = (1 &lt;&lt; 1),
     MPMediaPlaylistAttributeGenius  = (1 &lt;&lt; 2)
  };
  typedef NSInteger MPMediaPlaylistAttribute;
  </code></pre>
  
  <p>I want to log the value to the terminal, so i used </p>
  
  <p>NSLog(@"playlist attribute value:%@", [[playlist valueForProperty:MPMediaPlaylistPropertyPlaylistAttributes] stringValue]);</p>
  
  <p>However, it prints out a value of 0 every time. This means that either every playlist has the attribute "MPMediaPlaylistAttributeNone", but this doesnt make sense since it is going through many genius and on the go playlists as well.</p>
  
  <p>here is my entire code:</p>
  
  <pre><code>MPMediaQuery *myPlaylistsQuery = [MPMediaQuery playlistsQuery];
      NSLog(@"number of playlists total:%d", [[myPlaylistsQuery collections] count]);
      NSArray *playlists = [myPlaylistsQuery collections];
  
      for (MPMediaPlaylist *playlist in playlists) {
  
          NSInteger theAttributes;
  
          theAttributes = [[playlist valueForProperty:MPMediaPlaylistPropertyPlaylistAttributes] integerValue];
          NSLog(@"attribute:%d of playlist:%@", theAttributes, [playlist valueForProperty:MPMediaPlaylistPropertyName]);
      }
  </code></pre>
  
  <p>and here is the result, when i run the application on my iphone. many of these playlists are in fact genius playlists: </p>
  
  <p>attribute:0 of playlist:Purchased</p>
  
  <p>attribute:0 of playlist:Purchased on My iPhone </p>
  
  <p>attribute:0 of playlist:Army of Them </p>
  
  <p>attribute:0 of playlist:Blue</p>
  
  <p>attribute:0 of playlist:Closer</p>
  
  <p>attribute:0 of playlist:Crazy</p>
  
  <p>attribute:0 of playlist:Mad About You</p>
  
  <p>attribute:0 of playlist:Midnight</p>
  
  <p>attribute:0 of playlist:Something Elephants </p>
  
  <p>attribute:0 of playlist:Supermassive Black Hole</p>
  
  <p>attribute:0 of playlist:Take Me Away</p>
  
  <p>attribute:0 of playlist:The Mixed Tape</p>
  
  <p>attribute:0 of playlist:Time</p>
  
  <p>attribute:0 of playlist:All Around Me</p>
  
  <p>attribute:0 of playlist:anna's cd</p>
  
  <p>attribute:0 of playlist:Av</p>
  
  <p>attribute:0 of playlist:av 2 </p>
  
  <p>attribute:0 of playlist:Believe </p>
  
  <p>attribute:0 of playlist:BH </p>
  
  <p>attribute:0 of playlist:Boulevard of Broken Dreams</p>
  
  <p>attribute:0 of playlist:car 1</p>
  
  <p>attribute:0 of playlist:car 2</p>
  
  <p>attribute:0 of playlist:car 3</p>
  
  <p>Any ideas why every playlist is coming out as having 0 for the attributes?</p>
  
  <p>Again, thanks for your time!</p>