-
-
Save devongovett/17114 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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