Skip to content

Instantly share code, notes, and snippets.

@ivan3bx
ivan3bx / ITLibraryExample.m
Created September 7, 2013 18:40
Example of the ITLibrary API
NSError *error = nil;
ITLibrary *library = [ITLibrary libraryWithAPIVersion:@"1.0" error:&error];
if (library)
{
NSArray *playlists = library.allPlaylists;
NSArray *tracks = library.allMediaItems;
NSLog(@"Playlists count: %lu", [playlists count]);
NSLog(@"Tracks count: %lu", [tracks count]);
@ivan3bx
ivan3bx / loading_itunes_xml.m
Created September 7, 2013 04:35
just mucking around with iTunes XML data..
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *path = [NSString stringWithFormat:@"%@/Music/iTunes/iTunes Library.xml", NSHomeDirectory()];
NSData *xmlData;
NSDictionary *plist;
xmlData = [NSData dataWithContentsOfFile:path];
NSString *error;
NSPropertyListFormat format;
@ivan3bx
ivan3bx / gist:327641
Created March 10, 2010 07:33
Alternative to using OCMock for simple stubbing of NSHTTPURLResponse statusCode
/*
* Subclassing in this case wins over mocking
*/
@interface MockHTTPURLResponse : NSHTTPURLResponse {
NSInteger statusCode;
}
@property(readwrite,nonatomic) NSInteger statusCode;
@end
@ivan3bx
ivan3bx / gist:327614
Created March 10, 2010 07:11
Stubbing HTTP status code with OCMock
NSInteger result = 401;
const void *val = &result;
id mockResponse = [OCMockObject mockForClass:[NSHTTPURLResponse class]];
[[[mockResponse stub] andReturn:[NSValue value:val withObjCType:@encode(NSInteger)]] statusCode];