Permalink
Browse files

NS_ENUM instead of enum {} directly, and prefix category methods

  • Loading branch information...
1 parent a33325a commit e7e061e13bd81596745f82e31991cc9cbf972caa Zach Drayer committed Jun 6, 2014
View
4 WWDCDownloader/DOMIteration.h
@@ -8,9 +8,9 @@
#import <WebKit/WebKit.h>
@interface DOMNodeList (Additions)
-- (void) enumerateObjectsUsingBlock:(void (^)(DOMObject *obj, unsigned idx, BOOL *stop)) block;
+- (void) wwdc_enumerateObjectsUsingBlock:(void (^)(DOMObject *obj, unsigned idx, BOOL *stop)) block;
@end
@interface DOMHTMLCollection (Additions)
-- (void) enumerateObjectsUsingBlock:(void (^)(DOMHTMLElement *obj, unsigned idx, BOOL *stop)) block;
+- (void) wwdc_enumerateObjectsUsingBlock:(void (^)(DOMHTMLElement *obj, unsigned idx, BOOL *stop)) block;
@end
View
12 WWDCDownloader/DOMIteration.m
@@ -7,7 +7,7 @@
#import "DOMIteration.h"
-#define iterate \
+#define wwdc_iterate \
do { \
BOOL stop = NO; \
\
@@ -23,13 +23,15 @@
} while (0)
@implementation DOMNodeList (Additions)
-- (void) enumerateObjectsUsingBlock:(void (^)(DOMObject *obj, unsigned idx, BOOL *stop)) block {
- iterate;
+- (void) wwdc_enumerateObjectsUsingBlock:(void (^)(DOMObject *obj, unsigned idx, BOOL *stop)) block {
+ wwdc_iterate;
}
@end
@implementation DOMHTMLCollection (Additions)
-- (void) enumerateObjectsUsingBlock:(void (^)(DOMHTMLElement *obj, unsigned idx, BOOL *stop)) block {
- iterate;
+- (void) wwdc_enumerateObjectsUsingBlock:(void (^)(DOMHTMLElement *obj, unsigned idx, BOOL *stop)) block {
+ wwdc_iterate;
}
@end
+
+#undef wwdc_iterate
View
2 WWDCDownloader/WWDCURLRequest.h
@@ -24,5 +24,5 @@ typedef void (^WWDCRequestCompletionBlock)(WWDCURLRequest *request, WWDCURLRespo
@end
@interface NSOperationQueue (Additions)
-+ (NSOperationQueue *) requestQueue;
++ (NSOperationQueue *) wwdc_requestQueue;
@end
View
2 WWDCDownloader/WWDCURLRequest.m
@@ -249,7 +249,7 @@ + (WWDCURLResponse *) responseWithRemoteAddress:(NSString *) address localPath:(
#pragma mark -
@implementation NSOperationQueue (Additions)
-+ (NSOperationQueue *) requestQueue {
++ (NSOperationQueue *) wwdc_requestQueue {
static NSOperationQueue *requestQueue;
static dispatch_once_t pred;
View
20 WWDCDownloader/WWDCWebsiteInteractionController.m
@@ -47,7 +47,7 @@ Example HTML that we look for (with the formatting cleaned up):
#import <WebKit/WebKit.h>
-enum {
+typedef NS_ENUM(NSInteger, WWDCVideoQuality) {
WWDCVideoQualityNone = 0,
WWDCVideoQualitySD = (1 << 0),
WWDCVideoQualityHD = (1 << 1),
@@ -94,31 +94,31 @@ - (IBAction) download:(id) sender {
[self.downloadProgressBar setHidden:!_foundVideosPage];
// find content first
- [self.webView.mainFrameDocument.body.children enumerateObjectsUsingBlock:^(DOMHTMLElement *contentElement, unsigned contentIndex, BOOL *stopContentEnumeration) {
+ [self.webView.mainFrameDocument.body.children wwdc_enumerateObjectsUsingBlock:^(DOMHTMLElement *contentElement, unsigned contentIndex, BOOL *stopContentEnumeration) {
if (![contentElement.className isEqualToString:@"content"]) {
return;
}
// then find the list of videos container
- [contentElement.children enumerateObjectsUsingBlock:^(DOMHTMLElement *sectionElement, unsigned sectionIndex, BOOL *stopSectionEnumeration) {
+ [contentElement.children wwdc_enumerateObjectsUsingBlock:^(DOMHTMLElement *sectionElement, unsigned sectionIndex, BOOL *stopSectionEnumeration) {
if ([sectionElement.className rangeOfString:@"video-list"].location == NSNotFound) {
return;
}
// and find the section of the page that contains the actual list
- [sectionElement.children enumerateObjectsUsingBlock:^(DOMHTMLElement *subsectionElement, unsigned subsectionIndex, BOOL *stopSubsectionEnumeration) {
+ [sectionElement.children wwdc_enumerateObjectsUsingBlock:^(DOMHTMLElement *subsectionElement, unsigned subsectionIndex, BOOL *stopSubsectionEnumeration) {
if (![subsectionElement.tagName.lowercaseString isEqualToString:@"section"]) {
return;
}
// and now find the list itself
- [subsectionElement.children enumerateObjectsUsingBlock:^(DOMHTMLElement *unorderedListElement, unsigned unorderedListIndex, BOOL *stopUnorderedListEnumeration) {
+ [subsectionElement.children wwdc_enumerateObjectsUsingBlock:^(DOMHTMLElement *unorderedListElement, unsigned unorderedListIndex, BOOL *stopUnorderedListEnumeration) {
if (![unorderedListElement.tagName.lowercaseString isEqualToString:@"ul"]) {
return;
}
// finally, get each session's video/pdf in the list
- [unorderedListElement.children enumerateObjectsUsingBlock:^(DOMObject *listObject, unsigned listIndex, BOOL *stopListEnumeration) {
+ [unorderedListElement.children wwdc_enumerateObjectsUsingBlock:^(DOMObject *listObject, unsigned listIndex, BOOL *stopListEnumeration) {
if (_loggedIn) {
[self findDownloadsFromDOMLIElement:(DOMHTMLLIElement *)listObject];
} else {
@@ -169,7 +169,7 @@ - (void) downloadFromAnchorElement:(DOMHTMLAnchorElement *) anchorElement forSes
strongSelf.downloadProgressBar.doubleValue++;
};
- [[NSOperationQueue requestQueue] addOperation:request];
+ [[NSOperationQueue wwdc_requestQueue] addOperation:request];
self.downloadProgressBar.maxValue++;
}
@@ -182,7 +182,7 @@ - (void) findDownloadsFromDOMLIElement:(DOMHTMLLIElement *) liElement {
__block NSString *sessionName = nil;
- [[liElement.children tags:@"li"] enumerateObjectsUsingBlock:^(DOMObject *object, unsigned index, BOOL *stop) {
+ [[liElement.children tags:@"li"] wwdc_enumerateObjectsUsingBlock:^(DOMObject *object, unsigned index, BOOL *stop) {
DOMHTMLLIElement *innerLIElement = (DOMHTMLLIElement *)object;
if ([innerLIElement.className isEqualToString:@"title"]) {
sessionName = [innerLIElement.innerText copy];
@@ -191,7 +191,7 @@ - (void) findDownloadsFromDOMLIElement:(DOMHTMLLIElement *) liElement {
}
}];
- [[liElement.children tags:@"a"] enumerateObjectsUsingBlock:^(DOMObject *object, unsigned index, BOOL *stop) {
+ [[liElement.children tags:@"a"] wwdc_enumerateObjectsUsingBlock:^(DOMObject *object, unsigned index, BOOL *stop) {
DOMHTMLAnchorElement *anchorElement = (DOMHTMLAnchorElement *)object;
if ([anchorElement.href rangeOfString:@"devstreaming"].location == NSNotFound) {
@@ -215,7 +215,7 @@ - (void) findDownloadsFromDOMLIElement:(DOMHTMLLIElement *) liElement {
#pragma mark -
- (void) loginFromDOMLIElement:(DOMHTMLLIElement *) liElement {
- [[liElement.children tags:@"a"] enumerateObjectsUsingBlock:^(DOMObject *object, unsigned index, BOOL *stop) {
+ [[liElement.children tags:@"a"] wwdc_enumerateObjectsUsingBlock:^(DOMObject *object, unsigned index, BOOL *stop) {
DOMHTMLAnchorElement *anchorElement = (DOMHTMLAnchorElement *)object;
if ([anchorElement.href rangeOfString:@"login"].location != NSNotFound) {

0 comments on commit e7e061e

Please sign in to comment.