Guest User

Untitled

a guest
Feb 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. - (void)applicationDidFinishLaunching:(CPNotification)aNotification
  2. {
  3. connection = [[CPURLConnection alloc] initWithRequest:[CPURLRequest requestWithURL:"/index.php? username=Guest&password=&action=render&render=Playlists.php"] delegate:self startImmediately:NO];
  4. CPLog(connection);
  5. [connection start];
  6. }
  7.  
  8. - (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
  9. {
  10. //CPLog(data);
  11. if (connection == aConnection)
  12. {
  13. CPLog("hr,,");
  14. try
  15. {
  16. // CPLog("Now");
  17. var result = CPJSObjectCreateWithJSON(data);
  18. CPLog(result);
  19. }
  20. catch(e)
  21. {
  22. //CPLog("Error");
  23. return [self connection:aConnection didFailWithError: e];
  24. }
  25.  
  26. // do stuff with result
  27. CPLog([result description]);
  28. var x;
  29. for(x in result)
  30. {
  31. // alert(result[x]["Name"]);
  32. var name = result[x]["Name"];
  33. var url = result[x]["playlist_tracks_url"];
  34. [self addPlaylist:url withName:name];
  35. }
  36. connection = nil;
  37. }
  38. if(playlistConnection == aConnection)
  39. {
  40. CPLog("playlist connection");
  41. try
  42. {
  43. // CPLog("Now");
  44. var result = CPJSObjectCreateWithJSON(data);
  45. CPLog(result);
  46. }
  47. catch(e)
  48. {
  49. //CPLog("Error");
  50. return [self connection:aConnection didFailWithError: e];
  51. }
  52.  
  53. // do stuff with result
  54. CPLog([result description]);
  55. var x;
  56. for(x in result)
  57. {
  58. // alert(result[x]["Name"]);
  59. var name = result[x]["Name"];
  60. var url = result[x]["playlist_tracks_url"];
  61. [self addPlaylist:url withName:name];
  62. }
  63. connection = nil;
  64. }
  65. //CPLog("Nope");
  66. }
  67.  
  68. - (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
  69. {
  70. CPLog(anError);
  71. [self connectionDidFinishLoading:aConnection];
  72. }
  73.  
  74. - (void)connectionDidFinishLoading:(CPURLConnection)aConnection
  75. {
  76. if (connection == aConnection)
  77. {
  78. connection = nil;
  79. }
  80. }
Add Comment
Please, Sign In to add comment