Skip to content

Commit ab38b50

Browse files
Michael BeattieAlfredo Uribe
authored andcommitted
[#67863352] added comments
1 parent 806c24e commit ab38b50

4 files changed

Lines changed: 35 additions & 4 deletions

File tree

EasyReader/Application/Api/CSFeedSearcher.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@
77
//
88

99
#import "CSFeedSearcher.h"
10-
#import "FeedItem.h"
1110
#import "Feed.h"
1211

1312
@implementation CSFeedSearcher
1413

14+
/**
15+
* API requestor for feeds similar to user input
16+
*/
1517
- (void)feedsLike:(NSString *)name
1618
{
1719
[self searchForFeedsLike:name];
1820
}
1921

22+
/**
23+
* Call to the API that returns feeds similar to user input
24+
*/
2025
- (void)searchForFeedsLike:(NSString *)name
2126
{
2227
[Feed requestFeedsByName:name

EasyReader/Application/Controllers/Menu/CSMenuLeftViewController.m

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ - (void)viewDidLoad
4949
[super viewDidLoad];
5050
self.currentUser = [User current];
5151
self.feeds = [[NSMutableSet alloc] init];
52+
53+
// Setup the user and search datasources
5254
[self setUpDataSources];
5355

54-
// Setup feedSearch API
56+
// Setup feedSearch API requestor
5557
feedSearcher = [[CSFeedSearcher alloc] init];
5658

5759
// Set tableViewStyle
@@ -81,6 +83,8 @@ - (void)viewDidLoad
8183
for ( Feed *feed in addedFeeds ){
8284
[[self feeds] addObject:feed];
8385
}
86+
87+
// Update and switch to the userFeed data source
8488
self.tableView_feeds.dataSource = userFeedDataSource;
8589
[userFeedDataSource updateWithFeeds:self.feeds];
8690

@@ -104,7 +108,10 @@ - (void)viewDidLoad
104108

105109
- (void)setUpDataSources
106110
{
111+
// Lists feeds in the database
107112
userFeedDataSource = [[CSMenuUserFeedDataSource alloc] init];
113+
114+
// Lists feeds returned by the search API
108115
searchFeedDataSource = [[CSMenuSearchFeedDataSource alloc] init];
109116
}
110117

@@ -129,6 +136,8 @@ - (void)menuStateEventOccurred:(NSNotification *)notification {
129136
weakSelf.textField_searchInput.text = @"";
130137
[weakSelf.tableView_feeds setEditing:NO animated:YES];
131138
weakSelf.menuContainerViewController.panMode = MFSideMenuPanModeDefault;
139+
140+
// Reset to the users feeds
132141
weakSelf.tableView_feeds.dataSource = userFeedDataSource;
133142
[weakSelf.tableView_feeds reloadData];
134143
break;
@@ -137,11 +146,17 @@ - (void)menuStateEventOccurred:(NSNotification *)notification {
137146

138147
- (void)searchFieldDidChange
139148
{
149+
// If the searchInput has text
140150
if(self.textField_searchInput.text && self.textField_searchInput.text.length > 0){
151+
152+
// Create empty searchFeed set
141153
NSMutableSet *searchedFeeds = [[NSMutableSet alloc] init];
154+
155+
// Switch to the searchFeed datasource and update the table
142156
[searchFeedDataSource updateWithFeeds:searchedFeeds];
143157
self.tableView_feeds.dataSource = searchFeedDataSource;
144158

159+
// If the user is typing a url
145160
if([self.textField_searchInput.text hasPrefix:@"http"]){
146161
// Get the local context
147162
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
@@ -151,15 +166,20 @@ - (void)searchFieldDidChange
151166
customFeed.name = self.textField_searchInput.text;
152167
customFeed.url = self.textField_searchInput.text;
153168

169+
// Add custom feed to the searchFeeds
154170
[searchedFeeds addObject:customFeed];
155171
}
156172
else{
173+
// Return feeds from the API similar to user input
174+
// Add these feeds to the searchFeed datasource
157175
[feedSearcher feedsLike:self.textField_searchInput.text];
158176
}
159177

178+
// Reload the table with new searchFeeds
160179
[self.tableView_feeds reloadData];
161180
}
162181
else{
182+
// Switch to the userFeeds datasource
163183
self.tableView_feeds.dataSource = userFeedDataSource;
164184
[self.tableView_feeds reloadData];
165185
}

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuSearchFeedDataSource.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ - (id)init
2929
return self;
3030
}
3131

32-
32+
/**
33+
* Sets the feeds to those returned by the search
34+
*/
3335
- (void)updateWithFeeds:(NSMutableSet *)feeds
3436
{
3537
self.feeds = feeds;
3638
}
3739

40+
3841
#pragma mark - Count Methods
3942
/**
4043
* Determines the number of rows in each section

EasyReader/Application/Controllers/Menu/MenuDataSources/CSMenuUserFeedDataSource.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ - (id)init
2828
return self;
2929
}
3030

31-
31+
/**
32+
* Sets the feeds to those in the database
33+
*/
3234
- (void)updateWithFeeds:(NSMutableSet *)feeds
3335
{
3436
self.feeds = feeds;
3537
}
3638

39+
3740
#pragma mark - Count Methods
3841
/**
3942
* Determines the number of rows in each section

0 commit comments

Comments
 (0)