Skip to content

Instantly share code, notes, and snippets.

@devongovett
Created October 16, 2008 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devongovett/17114 to your computer and use it in GitHub Desktop.
Save devongovett/17114 to your computer and use it in GitHub Desktop.
docs = [CPDictionary dictionary];
var request = [CPURLRequest requestWithURL:"your xml file here!"];
listConnection = [CPURLConnection connectionWithRequest:request delegate:self];
//Connection Delegate Stuff
- (void)connection:(CPURLConnection) aConnection didReceiveData:(CPString)data
{
if (aConnection == listConnection){
var tmp = document.createElement("div");
tmp.innerHTML = data;
var arr = tmp.getElementsByTagName("a");
for(var i=0;i<arr.length;i++){
if(arr[i].innerHTML.indexOf("<img src=") == -1)
[docs setObject:arr[i].getAttribute("href") forKey:arr[i].innerHTML];
}
//set content of a Collection View if you want
[listCollectionView setContent: [[docs allKeys] copy]];
}
[self clearConnection: aConnection];
}
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPString)error
{
alert("Could not load :(");
[self clearConnection:aConnection];
}
- (void)clearConnection:(CPURLConnection)aConnection
{
//we no longer need to hold on to a reference to this connection
listConnection = nil;
}
-(void)connectionDidFinishLoading:(CPURLConnection)aConnection
{
//Yay!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment