• Stars
    star
    818
  • Rank 55,733 (Top 2 %)
  • Language
    Swift
  • License
    Other
  • Created over 11 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The iPhone version of News/YC, a Hacker News reader and interactive iOS application.

banner

About

News/YC is an iOS app that tries to do one thing, give you Hacker News and get the hell out of the way. If the app isn't doing something you feel it should, or if you think there's an easier way to get an action accomplished - open up an Issue! I want your feedback. This app was made by me, for my usage, so it probably won't line up with everybody's tastes and there is probably a huge group of people with better taste than me. Feel free to be vocal - it's the only way to make this app the best!

This app does not use the new HackerNews API, but instead relies on libHN for the interface to HN content.

App Store

  • 3.0
  • Swift

Table of Contents

General Architecture

This app is built in Swift, but is really a port of an existing app with a little bit clearer design and modularity of components. There are a few architecture decisions I made to make some things easier that may or may not be defacto architecture or MVC considerations. The first of which is...

HNNavigationBrain

This class is literally the arbiter for all navigation related activities. I made this class with the idea that I shouldn't have to constantly defer navigation-related logic up through a chain to meet a UIViewController which then actually does it. That's too much of a chain, and honestly too much of a hassle. I wanted the system to be slightly knowledgable about itself. I wanted to be able to navigate at any time I want.

Enter the Brain.

The navigation brain works by making every navigable View Controller a subclass of HNViewController which handles a lot of boilerplate logic like building the navigation bar and responding to theme changes, etc. The biggest thing this view controller does is listen for navigation notifications, and responding if they are valid. HNNavigationBrain initiates navigation by a bunch of possible methods (navigate to Posts, navigate to comments for Post, etc) and passes a newly instantiated HNViewController instance through the NSNotificationCenter to the top-most view controller in the UINavigationController's stack.

What this effectively means, is that anything can initiate navigation. All views, models, and controllers have this functionality thanks to the brain. This scheme is not without possible problems, however, but we try to minimize these as much as possible. Navigation events are fairly predictable reactions to button presses, so we don't have to worry so much about different classes calling navigation notifications at the same time. But it is beneficial to think about this as you commit and contribute to the project.

It's fairly easy to use the navigation brain as well:

HNNavigationBrain.navigateToComments(somePost)

HNTheme

HNTheme.currentTheme() acts as the main interface for all them and color related functionality of the app. The currentTheme() singleton instance determines how all UI color schemes are assigned, and handles the notifications blasted out when the theme is changed. All HNViewControllers and their subclasses override the resetUI() method to reset after a theme change.

Currently there are four themes in the app, two light (Day and Minima) and two dark (Night and SpaceOne). Since I'm an art guy myself, you can bet your butt there will be more themes and theme packs later.

View Controllers

As mentioned earlier, all navigable view controllers in the app are subclasses of HNViewController - but those don't account for all view controllers in the app.

HNViewController subclassed

  • HNPostsViewController
  • HNCommentsViewController
  • HNWebViewController

UIViewController subclassed

  • HNSubmissionViewController
  • HNNavigationViewController

What's Next?

Apart from library changes here and there whenever YC starts messing with the site site's HTML markup, here's the list of functionality I'd like to add:

  • Nesting Comments
  • Find text in comment strings
  • More themes!

More Repositories

1

Colours

A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.
Objective-C
3,094
star
2

CollapseClick

A collapsible list that functions like a UITableView, except you can collapse and open cells on a click. Feed it UIViews for what is shown when each cell is open. Works via delegation similar to UITableView.
Objective-C
537
star
3

BGUtilities

A collection of categories and class methods to make your iOS life easier.
Objective-C
164
star
4

libHN

The definitive Objective-C library for adding HackerNews to your iOS/Mac app.
Objective-C
150
star
5

iOS----BubbleButtonView

Dynamically fill a UIView with rounded-corner UIButtons based off of an array of strings. This class also sequentially animates the adding and removing of buttons for a nice UI touch.
Objective-C
99
star
6

SatelliteStore

A modernized block-based StoreKit wrapper for iOS
Objective-C
23
star
7

BTCDonationViewController

A UIViewController for making bitcoin donation simple.
Objective-C
20
star
8

StarField

A UIView subclass with moving stars. Looks sweet.
Objective-C
15
star
9

ImageCache

A shared cache class that saves UIImages to a Key/Value store and sets UI Elements with the image whenever it's loaded. The class also implements LRU dumping for smart memory management.
Objective-C
15
star
10

ColourClock

This project converts Time to Hex/RGB, and is quite beautiful to look at.
Objective-C
14
star
11

LoremIpsumObjC

LoremIpsum Generator for Objective-C. Just pass it the number of words you want, or if you want a special punctuation mark at the end.
Objective-C
5
star