H4XOR News is an iOS application designed to display top stories from Hacker News. The app fetches data from the Hacker News API and presents it in a SwiftUI-based interface, providing a clean and user-friendly experience. The app supports seamless navigation between story listings and detailed views, enabling users to stay up-to-date with the latest tech news.
- Top Stories Listing: Displays a list of the most popular stories from Hacker News.
- SwiftUI Interface: Modern and responsive UI built with SwiftUI.
- Story Details View: Provides more detailed information and a link to the full article.
- Swift
- SwiftUI
- Hacker News API
-
Fetching Data from API:
- The app retrieves data using the Hacker News API and handles JSON decoding.
func fetchStories() { if let url = URL(string: "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty") { URLSession.shared.dataTask(with: url) { data, response, error in if let safeData = data { // Parse the data } }.resume() } }
-
Story Listing View:
- SwiftUI is used to create a responsive list view that displays the fetched stories.
struct StoryListView: View { var body: some View { List(stories) { story in Text(story.title) } } }
-
Navigation and Story Details:
- The app allows users to tap on a story to navigate to a detailed view with more information.
struct StoryDetailView: View { var story: Story var body: some View { VStack { Text(story.title) Text(story.url) } } }
Here are some screenshots showing the key features and output of the application:
- Clone the repository:
git clone https://github.com/MalingaBandara/H4XOR-News-iOS-App.git
- Open the project in Xcode.
- Run the project on an iOS simulator or device.
The H4XOR News project was developed to demonstrate fetching and displaying API data in an iOS app using SwiftUI. Future enhancements may include adding search functionality, sorting options, and improved error handling.
This project is licensed under the MIT License.