I am beta-testing my first Android app, and have recently completed my second iOS app. Having taught myself how to program in both Swift and Java, I spent a lot of time lamenting the inability to easily convert code between the two. Sure, there are cross-platform solutions, but as an independent developer, I couldn’t afford to invest a ton of money in a paid system. Plus, I had already learned Swift, and this wasn’t helpful for many cross-platform solutions.
Below is a list-in-progress of concepts and objects that have parallels between the two operating systems and languages. Feel free to comment and make suggestions!
iOS | Android |
storyboard/nib | design/layout/xml |
constraints | layouts |
UIViewController | Activity/Fragment |
UIView | View |
UITableView | RecyclerView/LinearLayout |
UICollectionView | RecyclerView/GridLayout |
UIPickerView | Spinner |
UITextView/UITextField | EditText |
UILabel | TextView |
UIButton | Button/ImageButton |
UIImageView | ImageView |
UISwitch | Switch |
viewDidLoad() | onCreate() |
viewWillAppear() | onResume() |
viewWillDisappear() | onSuspend() |
NSNotification.postNotification() | sendBroadcast() |
NSNotification.addObserver() | BroadcastReceiver.onReceive() |
dispatch_async() | AsyncTask() |
Swift | Java |
Class | Class |
String | String |
Int | int/Integer |
Bool | boolean/Boolean |
Array | ArrayList/[] — example: String[] |
Dictionary | HashMap |
for i in i..<count { } | for (int i=0; i<count; i++) { } |
for item in array { } | for (String item : array) { } |
if x == 5 | if (x == 5) |
switch object | switch (object) |
case: x = 4; break; |
case: x = 4 |
I hope this is helpful to some other beginning programmers! Reinventing the wheel for each device is hard enough…not even knowing what the wheel is called is even worse!