12 Weeks as a iOS Developer Intern — Week Four
Week four flew by, here’s a bit of what I did this week~
I fixed merge conflicts and merged branches on my own for the first time, which was exciting! I also learned about consolidating UIViews, dynamic label creation and a bit more about constraints that depend on each other.
Consolidating UIViews
When building a complex screen that involve multiple UIViews, think about whether any of those UIViews can be reused instead of creating two separate UIView files that have almost the same code.
For example “Add Payment Method” and “Add Promo Code” are two UIViews inside of a ContentView in a ScrollView. They’re almost exactly the same initially but change after user interaction. Instead of having two UIView files, these two UIViews can be consolidated into one reusable UIView.
In the ReusableView, an enum is used to control for diff labels/diff behavior in the two views.
The UIViews are then initialized inside of the UIViewController with the Enum type.
Dynamic label creation
I thought text labels created dynamically based on data that was passed in, was the coolest thing ever!
These are two rows in a UITableView created from one custom UITableViewCell. The ingredient option labels are labels in a stackView. Notice the second row does not have custom ingredient options selected hence no labels are generated. These custom ingredient labels are generated inside an update cell function.
Constraints
If you have elements that will always be aligned in the same position, it is best to constrain these elements to each other instead of independent constraints.
ie: productLabel’s top constraint and priceLabel’s top constraint should be equal to quantityLabel’s top constraint. That way, if the top constraint needs to be offset by a bit, only the quantityLabel’s top constraint needs to be changed because the other label’s constraints are already dependent on that one constraint.
Some super helpful git commands I used this week:
1. Revert to prev commit
To see hashes of previous commits
git log
Once you get the correct hash for the commit you want to revert to:
git reset --hard hashOfCommitYouWantToRevertTo
2. Merging branches
First make sure you are on the branch you want to merge INTO
git checkout branchYouWantToMergeInto
Then upon making sure you are on the correct branch
git merge branchYouWantToMergeIn
which should result in:
3. Merge Conflicts
- merge conflict file paths will be shown in terminal
I like using Sublime to fix merge conflicts on the pbx proj file
subl pathOfPbxProj
- Fix pbx proj conflicts in sublime text editor
- Exit Xcode
- Open workspace with the following terminal command:
open *xcw*
- Fix other merge conflicts in workspace
That’s it for the week four post! 😊
Read about week three as an iOS developer intern here
Show your support with 👏 claps below, follow me on my iOS developer journey 😊 on Twitter