Skip to content

Commit ed810b0

Browse files
committed
Initial commit
0 parents  commit ed810b0

23 files changed

+4680
-0
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Ignore some Xcode auto-generated files
2+
build/
3+
*~.nib/
4+
5+
# Ignore user specific Xcode files
6+
# As only 1 developer, don't ignore them (breakpoints, env. vars etc)
7+
#*.perspective
8+
#*.perspectivev3
9+
#*.pbxuser
10+
#*.mode1v3
11+
#*.mode2v3
12+
13+
# OS X noise
14+
.DS_Store
15+
profile
16+
17+
# Backups created by text editors
18+
*~
19+
*.bak
20+
21+
# Object/generated files
22+
*.o
23+
*.pyc
24+
*.pyo

Classes/MWFeedInfo.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// MWFeedInfo.h
3+
// XML
4+
//
5+
// Created by Michael Waterfall on 10/05/2010.
6+
// Copyright 2010 d3i. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface MWFeedInfo : NSObject {
12+
13+
NSString *title;
14+
NSString *link;
15+
NSString *summary;
16+
17+
}
18+
19+
@property (nonatomic, copy) NSString *title;
20+
@property (nonatomic, copy) NSString *link;
21+
@property (nonatomic, copy) NSString *summary;
22+
23+
@end

Classes/MWFeedInfo.m

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// MWFeedInfo.m
3+
// XML
4+
//
5+
// Created by Michael Waterfall on 10/05/2010.
6+
// Copyright 2010 d3i. All rights reserved.
7+
//
8+
9+
#import "MWFeedInfo.h"
10+
11+
@implementation MWFeedInfo
12+
13+
@synthesize title, link, summary;
14+
15+
- (NSString *)description {
16+
NSMutableString *string = [[NSMutableString alloc] initWithString:@"\nMWFeedInfo\n"];
17+
if (title) [string appendFormat:@"Title: %@\n", title];
18+
if (link) [string appendFormat:@"Link: %@\n", link];
19+
if (summary) [string appendFormat:@"Summary: %@", summary];
20+
return [string autorelease];
21+
}
22+
23+
@end

Classes/MWFeedItem.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// MWFeedItem.h
3+
// XML
4+
//
5+
// Created by Michael Waterfall on 10/05/2010.
6+
// Copyright 2010 d3i. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface MWFeedItem : NSObject {
12+
13+
NSString *title;
14+
NSString *link;
15+
NSString *summary; // Description of item
16+
NSString *content; // More detailed content (if available)
17+
NSDate *date;
18+
19+
}
20+
21+
@property (nonatomic, copy) NSString *title;
22+
@property (nonatomic, copy) NSString *link;
23+
@property (nonatomic, copy) NSString *summary;
24+
@property (nonatomic, copy) NSString *content;
25+
@property (nonatomic, copy) NSDate *date;
26+
27+
@end

Classes/MWFeedItem.m

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// MWFeedItem.m
3+
// XML
4+
//
5+
// Created by Michael Waterfall on 10/05/2010.
6+
// Copyright 2010 d3i. All rights reserved.
7+
//
8+
9+
#import "MWFeedItem.h"
10+
11+
@implementation MWFeedItem
12+
13+
@synthesize title, link, summary, content, date;
14+
15+
- (NSString *)description {
16+
NSMutableString *string = [[NSMutableString alloc] initWithString:@"\nMWFeedItem\n"];
17+
if (title) [string appendFormat:@"Title: %@\n", title];
18+
if (link) [string appendFormat:@"Link: %@\n", link];
19+
if (date) [string appendFormat:@"Date: %@\n", date];
20+
if (summary) [string appendFormat:@"Summary: %@\n", summary];
21+
if (content) [string appendFormat:@"Content: %@", content];
22+
return [string autorelease];
23+
}
24+
25+
@end

Classes/MWFeedParser.h

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//
2+
// MWFeedParser.h
3+
// XML
4+
//
5+
// Created by Michael Waterfall on 08/05/2010.
6+
// Copyright 2010 d3i. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "MWFeedInfo.h"
11+
#import "MWFeedItem.h"
12+
13+
// Debug Logging
14+
#if 0
15+
#define MWLog(x, ...) NSLog(x, ## __VA_ARGS__);
16+
#else
17+
#define MWLog(x, ...)
18+
#endif
19+
20+
// Class
21+
@class MWFeedParser;
22+
23+
// Types
24+
typedef enum { ConnectionTypeAsynchronously, ConnectionTypeSynchronously } ConnectionType;
25+
typedef enum { ParseTypeFull, ParseTypeItemsOnly, ParseTypeInfoOnly } ParseType;
26+
typedef enum { FeedTypeUnknown, FeedTypeRSS, FeedTypeAtom } FeedType;
27+
28+
// Delegate
29+
@protocol MWFeedParserDelegate <NSObject>
30+
@optional
31+
- (void)feedParserDidStart:(MWFeedParser *)parser;
32+
- (void)feedParser:(MWFeedParser *)parser didParseFeedInfo:(MWFeedInfo *)info;
33+
- (void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item;
34+
- (void)feedParserDidFinish:(MWFeedParser *)parser;
35+
- (void)feedParser:(MWFeedParser *)parser didFailWithError:(NSError *)error;
36+
@end
37+
38+
// Class
39+
@interface MWFeedParser : NSObject {
40+
41+
// Required
42+
id <MWFeedParserDelegate> delegate;
43+
NSString *url;
44+
45+
// Connection
46+
NSURLConnection *urlConnection;
47+
NSMutableData *asyncData;
48+
ConnectionType connectionType;
49+
50+
// Parsing
51+
ParseType feedParseType;
52+
NSXMLParser *feedParser;
53+
FeedType feedType;
54+
NSDateFormatter *dateFormatterRFC822, *dateFormatterRFC3339;
55+
BOOL hasEncounteredItems; // Whether the parser has started parsing items
56+
BOOL aborted; // Whether parse stopped due to abort
57+
58+
// Parsing Data
59+
NSString *currentPath;
60+
NSMutableString *currentText;
61+
NSDictionary *currentElementAttributes;
62+
MWFeedItem *item;
63+
MWFeedInfo *info;
64+
65+
}
66+
67+
// Properties
68+
@property (nonatomic, assign) id <MWFeedParserDelegate> delegate;
69+
@property (nonatomic, copy) NSString *url;
70+
71+
// Feed Downloading Properties
72+
@property (nonatomic, retain) NSURLConnection *urlConnection;
73+
@property (nonatomic, retain) NSMutableData *asyncData;
74+
@property (nonatomic) ConnectionType connectionType;
75+
76+
// Parsing Properties
77+
@property (nonatomic) ParseType feedParseType;
78+
@property (nonatomic, retain) NSXMLParser *feedParser;
79+
@property (nonatomic, retain) NSString *currentPath;
80+
@property (nonatomic, retain) NSMutableString *currentText;
81+
@property (nonatomic, retain) NSDictionary *currentElementAttributes;
82+
@property (nonatomic, retain) MWFeedItem *item;
83+
@property (nonatomic, retain) MWFeedInfo *info;
84+
85+
// NSObject Methods
86+
- (id)initWithFeedURL:(NSString *)feedURL;
87+
88+
// Parsing Methods
89+
- (void)reset;
90+
- (void)parse;
91+
- (void)startParsingData:(NSData *)data;
92+
93+
// Misc
94+
- (void)finishParsing;
95+
- (NSString *)linkFromAtomLinkAttributes:(NSDictionary *)attributes;
96+
97+
// Dates
98+
- (NSDate *)dateFromRFC822String:(NSString *)dateString;
99+
- (NSDate *)dateFromRFC3339String:(NSString *)dateString;
100+
101+
@end

0 commit comments

Comments
 (0)