Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)applicationDidFinishLaunching:(CPNotification)aNotification
- {
- connection = [[CPURLConnection alloc] initWithRequest:[CPURLRequest requestWithURL:"/index.php? username=Guest&password=&action=render&render=Playlists.php"] delegate:self startImmediately:NO];
- CPLog(connection);
- [connection start];
- }
- - (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
- {
- //CPLog(data);
- if (connection == aConnection)
- {
- CPLog("hr,,");
- try
- {
- // CPLog("Now");
- var result = CPJSObjectCreateWithJSON(data);
- CPLog(result);
- }
- catch(e)
- {
- //CPLog("Error");
- return [self connection:aConnection didFailWithError: e];
- }
- // do stuff with result
- CPLog([result description]);
- var x;
- for(x in result)
- {
- // alert(result[x]["Name"]);
- var name = result[x]["Name"];
- var url = result[x]["playlist_tracks_url"];
- [self addPlaylist:url withName:name];
- }
- connection = nil;
- }
- if(playlistConnection == aConnection)
- {
- CPLog("playlist connection");
- try
- {
- // CPLog("Now");
- var result = CPJSObjectCreateWithJSON(data);
- CPLog(result);
- }
- catch(e)
- {
- //CPLog("Error");
- return [self connection:aConnection didFailWithError: e];
- }
- // do stuff with result
- CPLog([result description]);
- var x;
- for(x in result)
- {
- // alert(result[x]["Name"]);
- var name = result[x]["Name"];
- var url = result[x]["playlist_tracks_url"];
- [self addPlaylist:url withName:name];
- }
- connection = nil;
- }
- //CPLog("Nope");
- }
- - (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
- {
- CPLog(anError);
- [self connectionDidFinishLoading:aConnection];
- }
- - (void)connectionDidFinishLoading:(CPURLConnection)aConnection
- {
- if (connection == aConnection)
- {
- connection = nil;
- }
- }
Add Comment
Please, Sign In to add comment