-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
documentation missing #94
Comments
@dragonsKnight5 Hello! What documentation we have is mostly in the header files, which are in the For examples, have a look at an old version of the read me. I figure most new code using HTMLReader would be in Swift, so I converted the examples, but that's awesome to hear there's still some new Objective-C being written in the world. Let me know if there's anything specific you're curious about in the code, or if you have any questions about how to use HTMLReader! |
How do I get a list of elements using a class? Thank you for getting back to me so quickly |
You'll need to make an HTMLDocument, using e.g. HTMLDocument *doc = [HTMLDocument documentWithString:coolString];
NSArray *elements = [doc nodesMatchingSelector:@".updog"]; Let me know if that helps! |
That was a big help, thank you very much. I know the next question is outside the scope of HTMLReader, but I'm hoping you can direct me Thank you again for patience and help |
I've worked around the issue using
I know this is on the main thread which is bad practice but I can't find a way to get the |
I suspect the issue is that URLSession does its work in the background and calls you later. For example: [[[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:
^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"hello from the completion handler");
NSDictionary *headers = [(NSHTTPURLResponse *)response allHeaderFields];
HTMLDocument *doc = [HTMLDocument documentWithData:data
contentTypeHeader:headers[@"Content-Type"]];
// you can work with the document inside this block all you like
// e.g. call a method and pass in the document
// (you probably want to dispatch_async on to the main queue first)
}] resume];
// outside the completion block, execution continues without waiting
NSLog(@"hello from after resuming the session task"); If you run that, you should see logs in this order:
The completion block is called in the background after the URLSession does its work, so execution in your current queue continues immediately after resuming the task. I looked around briefly but didn’t find any great NSURLSession tutorials. Search for that (URLSession is the Swift name so you might have better luck keeping the NS prefix) and look at a few, you'll probably start to see some patterns. |
Thanks for getting back to me so quickly to retrieve hyperlinks I think I use the same approach you outlined above just with the |
Exactly right. One way to get all the links might be |
with your greatly appreciated help, I've managed to filter down to div's using a The debugger shows me that the value I want is in attributes _map but nothing Thank you for taking the time to help me with this, objective-c isn't my current Best regards |
HTMLElement has an NSString *url = aElement[@"href"];
NSString *url2 = aElement.attributes[@"href"]; And it's my pleasure! Objective-C is kinda crufty (it's a few decades old at this point), but learning it helped me understand objects and methods in a way that other languages didn't, so I'll always be fond of it. |
I can't seem to find any documentation anywhere, majority of the .m files had little
to no comments within them. Makes it difficult to know what some of the functions
with in actually do.
Additionally, some code usage examples would be helpful. The examples in the root
level README file appear to be swift code, not very useful if required to use
objective-c
Best regards
dragonsKnight5
The text was updated successfully, but these errors were encountered: