Home

Awesome

LastFm - block based Last.fm SDK for iOS and Mac OS X

Badge w/ Version Badge w/ Platform

Loosely based on LastFMService from the old Last.fm iPhone app, but non-blocking, more readable, much easier to use (and to extend) and with less dependencies.

Features

Usage

// Set the Last.fm session info
[LastFm sharedInstance].apiKey = @"xxx";
[LastFm sharedInstance].apiSecret = @"xxx";
[LastFm sharedInstance].session = session;
[LastFm sharedInstance].username = username;

// Get artist info
[[LastFm sharedInstance] getInfoForArtist:@"Pink Floyd" successHandler:^(NSDictionary *result) {
    NSLog(@"result: %@", result);
} failureHandler:^(NSError *error) {
    NSLog(@"error: %@", error);
}];

// Scrobble a track
[[LastFm sharedInstance] sendScrobbledTrack:@"Wish You Were Here" byArtist:@"Pink Floyd" onAlbum:@"Wish You Were Here" withDuration:534 atTimestamp:(int)[[NSDate date] timeIntervalSince1970] successHandler:^(NSDictionary *result) {
    NSLog(@"result: %@", result);
} failureHandler:^(NSError *error) {
    NSLog(@"error: %@", error);
}];

Save the username and session you get with getSessionForUser:password:successHandler:failureHandler: somewhere, for example in NSUserDefaults, and on app start up set it back on [LastFm sharedInstance].username and [LastFm sharedInstance].session.

See the included iOS project for examples on login, logout, getting artist info and more.

Example app

There's an extensive example app available which handles login, logout, getting lots of artists in a tableview and showing their details, caching, canceling API calls, and much more.

To install the example app, you need to use CocoaPods: pod install. You can also try it by running pod try LastFm.

The example app only works in iOS 5 and higher due to the usage of storyboards. The SDK itself works in iOS 4 and higher.

Installation

You can install LastFm with CocoaPods. Just add the following line to your Podfile, and run pod install:

pod 'LastFm'

You can also simply clone the repository and drag the LastFm subfolder into your Xcode project. Be sure to install KissXML yourself.

Requirements

Issues and questions

Have a bug? Please create an issue on GitHub!

Apps using LastFm

Are you using LastFm in your iOS or Mac OS X app? Send a pull request with an updated README.md file to be included.

Test the LastFM API on RapidAPI.

License

LastFm is available under the MIT license. See the LICENSE file for more info.