DEV Community

Kien Nguyen Chi
Kien Nguyen Chi

Posted on

Hacktoberfest - Working with Swift

Project Introduction

๐Ÿ‘‰ Since starting of this semester, I took an IOS app development class. I was impressed by how XCode is convenient for the user to build the app interface, it is like dragging and dropping things in Adobe Photoshop.

๐Ÿ‘‰During the Hacktoberfest month, I wanted to work on an open source app in Swift language to explore how the IOS app truly works in the real world.

๐Ÿ‘‰The project is about Bookmark containing saved important links with categories for user to read them later. You can take a look at its GitHub Repo or my Folked Repo.

Project Issue

โ“I took an issue to add favorite feature to the app. With the following links display, whenever an user clicks on the bookmark button besides it. It would pin to the top of the list

๐Ÿ‘‰I spent hours to read through the project for to find where to put my code in, run the Simulator to see how the app works.

๐Ÿ‘‰I took me a lot of time to complete this project since I don't have a Mac yet, it is inconvenient to work with IOS app because XCode serves Mac user only. I had to borrow a Mac from my friend, installed the Xcode 12GB with my slow Internet connection, wrote the code, ran it, returned to her and borrowed back one day.

๐Ÿ”—This is my filing Issue on GitHub.

Project Process

I knew that what I have exactly to do. First step, I needed to get the data from the view, the table cell data and its index.

var linkView = sender.superview
while let view = linkView, !(view is UITableViewCell) {
     linkView = view.superview
}
guard let tableCell = linkView as? UITableViewCell else {return}
guard let indexPath = tableView.indexPath(for: tableCell) else {return}
Enter fullscreen mode Exit fullscreen mode

Next, I needed to remove the link from the current index, which was currently showing on the screen.

let link = self.links[indexPath.row]
self.links.remove(at: indexPath.row)
Enter fullscreen mode Exit fullscreen mode

Next, I needed to insert it at index 0, because after I added it to the bookmark, it would stay on top of the list.

self.links.insert(link, at: 0)
Enter fullscreen mode Exit fullscreen mode

In final step, I needed to save my modification and reloaded the interface.

self.saveLink()
self.tableView.reloadData()
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”—This is my Pull Request on GitHub.

Conclusion

๐Ÿ‘‰The owner of this repo is so slow in replying, which sometimes inconvenient to me to interact. It may take up to a week for a reply.

๐Ÿ‘‰Overall, it is fantastic to work on an actual open source IOS app in the real world. I can see some very similar code structures and designing tools that I learnt in class. Wanna keep falling in love with Swift and Xcode, I really need to save money to get a Mac.

โœ”๏ธDuring the Hacktoberfest, I worked with total 4 different programming languages/framework, which would make me so excited about open source programming. I had try Rust, Vue, React and Swift, very unfamiliar to me a month ago, but familiar now.

Top comments (0)