diff --git a/HackerNews.xcworkspace/xcuserdata/Vetrichelvan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/HackerNews.xcworkspace/xcuserdata/Vetrichelvan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
index fb17bc1..40e25fa 100644
--- a/HackerNews.xcworkspace/xcuserdata/Vetrichelvan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
+++ b/HackerNews.xcworkspace/xcuserdata/Vetrichelvan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
@@ -10,11 +10,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HackerNews/HomeTableViewController.m"
- timestampString = "456086269.667543"
+ timestampString = "456089986.571831"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "223"
- endingLineNumber = "223"
+ startingLineNumber = "221"
+ endingLineNumber = "221"
landmarkName = "-tableView:cellForRowAtIndexPath:"
landmarkType = "5">
@@ -26,43 +26,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HackerNews/HomeTableViewController.m"
- timestampString = "456085509.620368"
+ timestampString = "456089986.571831"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "124"
- endingLineNumber = "124"
- landmarkName = "-getStoryDataOfItem:usingNewIDs:"
- landmarkType = "5">
-
-
-
-
-
-
-
-
@@ -74,11 +42,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HackerNews/HomeTableViewController.m"
- timestampString = "456086269.667543"
+ timestampString = "456089986.571831"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "312"
- endingLineNumber = "312"
+ startingLineNumber = "310"
+ endingLineNumber = "310"
landmarkName = "-tableView:didSelectRowAtIndexPath:"
landmarkType = "5">
@@ -90,11 +58,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HackerNews/HomeTableViewController.m"
- timestampString = "456086269.667543"
+ timestampString = "456089986.571831"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "181"
- endingLineNumber = "181"
+ startingLineNumber = "179"
+ endingLineNumber = "179"
landmarkName = "-viewWillAppear"
landmarkType = "5">
@@ -106,27 +74,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HackerNews/HomeTableViewController.m"
- timestampString = "456086259.74754"
- startingColumnNumber = "9223372036854775807"
- endingColumnNumber = "9223372036854775807"
- startingLineNumber = "126"
- endingLineNumber = "126"
- landmarkName = "-getStoryDataOfItem:usingNewIDs:"
- landmarkType = "5">
-
-
-
-
diff --git a/HackerNews/HomeTableViewController.m b/HackerNews/HomeTableViewController.m
index c28f1ad..b3b43e7 100644
--- a/HackerNews/HomeTableViewController.m
+++ b/HackerNews/HomeTableViewController.m
@@ -18,22 +18,25 @@
@interface HomeTableViewController ()
-@property NSMutableArray *temporaryTop500StoriesIds;
-@property NSMutableArray *storyEventRefs;
-@property NSMutableArray *dataArr;
-@property NSMutableArray *heights;
+@property (nonatomic, strong) NSMutableArray *temporaryTop500StoriesIds;
+@property (nonatomic, strong) NSMutableArray *storyEventRefs;
+@property (nonatomic, strong) NSMutableArray *dataArr;
+@property (nonatomic, strong) NSMutableArray *heights;
@property (nonatomic, assign) NSInteger counter;
@property (nonatomic, strong) StoryTableViewCell *prototypeCell;
-
-
-
-
@end
-@implementation HomeTableViewController
+@implementation HomeTableViewController
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+ self = [super initWithCoder:aDecoder];
+ self.datasourceName = @"topstories";
+ self.loadMsg = @"Fetching Top Stories";
+ self.navTitle = @"Top Stories";
+ return self;
+}
#pragma mark - FireBase API
@@ -56,18 +59,18 @@ - (void)getTopStories {
-
-// NSArray *tempArray = [self.dataArr subarrayWithRange:NSMakeRange(0, 10)];
-//
-// [self.temporaryTop100StoriesIds addObjectsFromArray:tempArray];
-
+ // NSArray *tempArray = [self.dataArr subarrayWithRange:NSMakeRange(0, 10)];
+ //
+ // [self.temporaryTop100StoriesIds addObjectsFromArray:tempArray];
+
+
self.temporaryTop500StoriesIds = [snapshot.value mutableCopy];
-// NSArray *uniques = Underscore.uniq(self.temporaryTop100StoriesIds);
-//
-// NSLog (@"Number of elements in array = %d", [uniques count]);
+ // NSArray *uniques = Underscore.uniq(self.temporaryTop100StoriesIds);
+ //
+ // NSLog (@"Number of elements in array = %d", [uniques count]);
[self getStoryDescriptionsUsingNewIDs:YES];
@@ -75,7 +78,7 @@ - (void)getTopStories {
} withCancelBlock:^(NSError *error) {
NSLog(@"%@", error.description);
}];
-
+
}
- (void)getStoryDescriptionsUsingNewIDs:(BOOL)usingNewIDs{
@@ -86,11 +89,11 @@ - (void)getStoryDescriptionsUsingNewIDs:(BOOL)usingNewIDs{
}
}
else{
-// [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"lastRefreshDate"];
-//
-// for(NSNumber *itemNumber in self.top100StoriesIds){
-// [self getStoryDataOfItem:itemNumber usingNewIDs:usingNewIDs];
-// }
+ // [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"lastRefreshDate"];
+ //
+ // for(NSNumber *itemNumber in self.top100StoriesIds){
+ // [self getStoryDataOfItem:itemNumber usingNewIDs:usingNewIDs];
+ // }
}
}
@@ -101,7 +104,7 @@ - (void)getStoryDataOfItem:(NSNumber *)itemNumber usingNewIDs:(BOOL)usingNewIDs{
NSString *urlString = [NSString stringWithFormat:@"https://hacker-news.firebaseio.com/v0/item/%@",itemNumber];
-// NSLog(@"%@", itemNumber);
+ // NSLog(@"%@", itemNumber);
Firebase *storyDescriptionRef = [[Firebase alloc] initWithUrl:urlString];
@@ -111,7 +114,7 @@ - (void)getStoryDataOfItem:(NSNumber *)itemNumber usingNewIDs:(BOOL)usingNewIDs{
//NSDictionary *responseDictionary = snapshot.value;
- NSLog(@"%@", snapshot.value);
+ // NSLog(@"%@", snapshot.value);
if(snapshot.value != [NSNull null]){
[self.tableView beginUpdates];
[self.storiesArray addObject:snapshot.value];
@@ -119,15 +122,15 @@ - (void)getStoryDataOfItem:(NSNumber *)itemNumber usingNewIDs:(BOOL)usingNewIDs{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
-// [self.tableView reloadData];
+ // [self.tableView reloadData];
}
-
+
self.counter++;
HUD.progress = (float)self.counter / self.temporaryTop500StoriesIds.count;
if (self.counter == self.temporaryTop500StoriesIds.count) {
[HUD hide:YES];
}
-
+
} withCancelBlock:^(NSError *error) {
@@ -141,12 +144,7 @@ - (void)viewDidLoad {
// Initialize array that will store stories.
self.storiesArray = [[NSMutableArray alloc] init];
self.heights = [[NSMutableArray alloc] init];
- self.datasourceName = @"topstories";
- self.loadMsg = @"Fetching Top Stories";
- self.navTitle = @"Top Stories";
-
-
self.navigationController.navigationBar.topItem.title = self.navTitle;
@@ -160,11 +158,11 @@ - (void)viewDidLoad {
//HUD.labelText = @"Fetching Stories";
HUD.detailsLabelText = self.loadMsg;
HUD.mode = MBProgressHUDModeDeterminate;
-
-// [HUD showWhileExecuting:@selector(doSomeFunkyStuff) onTarget:self withObject:nil animated:YES];
+
+ // [HUD showWhileExecuting:@selector(doSomeFunkyStuff) onTarget:self withObject:nil animated:YES];
//self.title = @"Top Stories";
-
+
[self.view addSubview:HUD];
[HUD show:YES];
@@ -176,8 +174,8 @@ - (void)viewDidLoad {
}
--(void) viewWillAppear {
- self.navTitle = @"Top Stories";
+- (void)viewWillAppear:(BOOL)animated {
+ [super viewWillAppear:animated];
self.navigationController.navigationBar.topItem.title = self.navTitle;
self.title = self.navTitle;
}
@@ -204,7 +202,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
-
+
//NSLog(@"%@", snapshot.value);
return [self.storiesArray count];
}
@@ -214,19 +212,19 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
{
-// static NSString *CellIdentifier = @"storyCell";
-// StoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-//
-
+ // static NSString *CellIdentifier = @"storyCell";
+ // StoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ //
+
StoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"storyCell" forIndexPath:indexPath];
- if (cell==nil) {
-
- NSArray* storyObject = [[NSBundle mainBundle] loadNibNamed:@"CurrentOffersInfoView" owner:self options:nil];
-
- cell = [storyObject firstObject];
- }
+ if (cell==nil) {
+
+ NSArray* storyObject = [[NSBundle mainBundle] loadNibNamed:@"CurrentOffersInfoView" owner:self options:nil];
+
+ cell = [storyObject firstObject];
+ }
@@ -255,20 +253,20 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
if([story valueForKey:@"deleted"]){
} else {
-
- // Apply the data to each row
- cell.titleLabel.text = [story valueForKey:@"title"];
- cell.authorWithTimeLabel.text = [NSString stringWithFormat:@"by %@, %@", [story valueForKey:@"by"], ago];
- cell.commentLabel.text = [NSString stringWithFormat:@"%@", commentCountText];
- cell.scoreLabel.text = [NSString stringWithFormat:@"%@", [story valueForKey:@"score"]];
- cell.sourceLabel.text = urlString.length > 0 ? reducedUrl : @"";
- cell.typeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", [story valueForKeyPath:@"type"]]];
-
- cell.accessoryType = UITableViewCellAccessoryNone;
-
- cell.titleLabel.numberOfLines = 0;
- [cell.titleLabel sizeToFit];
-
+
+ // Apply the data to each row
+ cell.titleLabel.text = [story valueForKey:@"title"];
+ cell.authorWithTimeLabel.text = [NSString stringWithFormat:@"by %@, %@", [story valueForKey:@"by"], ago];
+ cell.commentLabel.text = [NSString stringWithFormat:@"%@", commentCountText];
+ cell.scoreLabel.text = [NSString stringWithFormat:@"%@", [story valueForKey:@"score"]];
+ cell.sourceLabel.text = urlString.length > 0 ? reducedUrl : @"";
+ cell.typeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", [story valueForKeyPath:@"type"]]];
+
+ cell.accessoryType = UITableViewCellAccessoryNone;
+
+ cell.titleLabel.numberOfLines = 0;
+ [cell.titleLabel sizeToFit];
+
}
//[HUD hide:YES];
[cell layoutIfNeeded];
@@ -283,25 +281,25 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
-//
+//
// NSDictionary *story = [self.storiesArray objectAtIndex:indexPath.row];
// NSString* text = [story valueForKey:@"title"];
// NSAttributedString * attributedString = [[NSAttributedString alloc] initWithString:text attributes:
// @{ NSFontAttributeName: [UIFont systemFontOfSize:16]}];
-//
+//
// //its not possible to get the cell label width since this method is called before cellForRow so best we can do
// //is get the table width and subtract the default extra space on either side of the label.
// CGSize constraintSize = CGSizeMake(300 - 30, MAXFLOAT);
-//
+//
// CGRect rect = [attributedString boundingRectWithSize:constraintSize options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) context:nil];
-//
+//
// //NSLog(@"Output is: \"%d\"", rect.size.height);
-//
+//
// //Add back in the extra padding above and below label on table cell.
// rect.size.height = rect.size.height + 23;
-//
+//
// //if height is smaller than a normal row set it to the normal cell height, otherwise return the bigger dynamic height.
-//
+//
// return (rect.size.height < 44 ? 95 : 115);
// //return 95;
//}
@@ -311,7 +309,7 @@ -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *
NSDictionary *story = [self.storiesArray objectAtIndex:indexPath.row];
//NSString *fullURL = [story valueForKey:@"url"];
//if(indexPath.row == 0) {
- [self performSegueWithIdentifier:@"topStoriestoWebView" sender:story];
+ [self performSegueWithIdentifier:@"topStoriestoWebView" sender:story];
//}
}
@@ -327,23 +325,23 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
}
//-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
-//
-//
+//
+//
// //1. Setup the CATransform3D structure
// CATransform3D rotation;
// rotation = CATransform3DMakeRotation( (90.0*M_PI)/180, 0.0, 0.7, 0.4);
// rotation.m34 = 1.0/ -600;
-//
-//
+//
+//
// //2. Define the initial state (Before the animation)
// cell.layer.shadowColor = [[UIColor blackColor]CGColor];
// cell.layer.shadowOffset = CGSizeMake(10, 10);
// cell.alpha = 0;
-//
+//
// cell.layer.transform = rotation;
// cell.layer.anchorPoint = CGPointMake(0, 0.5);
-//
-//
+//
+//
// //3. Define the final state (After the animation) and commit the animation
// [UIView beginAnimations:@"rotation" context:NULL];
// [UIView setAnimationDuration:0.8];
diff --git a/HackerNews/JobsTableViewController.m b/HackerNews/JobsTableViewController.m
index e975f48..8eddf52 100644
--- a/HackerNews/JobsTableViewController.m
+++ b/HackerNews/JobsTableViewController.m
@@ -15,26 +15,19 @@ @interface JobsTableViewController ()
@implementation JobsTableViewController
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+ self = [super initWithCoder:aDecoder];
+ self.datasourceName = @"jobstories";
+ self.loadMsg = @"Fetching Jobs";
+ self.navTitle = @"Jobs";
+ return self;
+}
+
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-- (NSString *)datasourceName {
-
- return @"jobstories";
-}
-
-- (NSString *)loadMsg {
-
- return @"Fetching Jobs";
-}
-
-- (NSString *)navTitle {
-
- return @"Jobs";
-}
-
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *story = [self.storiesArray objectAtIndex:indexPath.row];
@@ -61,13 +54,13 @@ - (void)didReceiveMemoryWarning {
}
/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
-}
-*/
+ #pragma mark - Navigation
+
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
+ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ // Get the new view controller using [segue destinationViewController].
+ // Pass the selected object to the new view controller.
+ }
+ */
@end
diff --git a/HackerNews/LatestTableViewController.m b/HackerNews/LatestTableViewController.m
index a85d766..bd9935a 100644
--- a/HackerNews/LatestTableViewController.m
+++ b/HackerNews/LatestTableViewController.m
@@ -16,36 +16,27 @@ @interface LatestTableViewController ()
@implementation LatestTableViewController
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+ self = [super initWithCoder:aDecoder];
+ self.datasourceName = @"newstories";
+ self.loadMsg = @"Fetching Latest";
+ self.navTitle = @"Latest Stories";
+ return self;
+}
+
- (void)viewDidLoad {
//self.datasourceName = @"newstories";
HUD.detailsLabelText = @"Fetching Latest Stories";
- //self.navigationController.navigationBar.topItem.title = @"Latest Stories";
+ //self.navigationController.navigationBar.topItem.title = @"Latest Stories";
[super viewDidLoad];
-
- // Do any additional setup after loading the view.
-}
-
-
-- (NSString *)datasourceName {
- return @"newstories";
-}
-
-- (NSString *)loadMsg {
-
- return @"Fetching Latest";
-}
-
-
-- (NSString *)navTitle {
-
- return @"Latest Stories";
+ // Do any additional setup after loading the view.
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
@@ -74,13 +65,13 @@ - (void)didReceiveMemoryWarning {
}
/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
-}
-*/
+ #pragma mark - Navigation
+
+ // In a storyboard-based application, you will often want to do a little preparation before navigation
+ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ // Get the new view controller using [segue destinationViewController].
+ // Pass the selected object to the new view controller.
+ }
+ */
@end