Thinc. First Code iOS (To be beginner iOS developer)
“ Be a beginner to be a professional ” is a normal thing that everyone knows, but it’s quite hard to know how to become a beginner. Don’t worry, we’ll be together.
Two things for being iOS beginner
- KNOW WHAT YOU WANT : if you don’t know what to do, it will be hard to start doing something, right? If you have actual things you wanna do, you’re absolutely get to know it very quickly. It’s like you ‘re setting your goal and then you’re starting get things finished step by step.
- KNOW WHERE TO GO : you know nowadays we’re in globalization which you can connect to all things around the world easily. You can get to know in this magic place. www.github.com is the special place for all dev should know. This place contains lots of things you might need in the future.
Basic things you should know before we start
- Xcode Program which you can easily find in App store
- Swift Language
Requirements
- macOS High Sierra
Language needed >> Swift 4
Swift is a new programming language for iOS, macOS, watchOS, and tvOS app development. Starter for Swift Language : Swift Basis such as Data type, Condition type, Collection type, Function
Important beginning file in Xcode
In Navigation Pane, you’ll see a lot of files
- AppDelegate > It’s file that handles states of application
- ViewController > It’s a code that controls the process of application
- Storyboard > Place where you design the interface of application
- LauchScreenStoryboard > It is the first place that application will launch
- Asset.xcasset > It’s place you put the bunch of images you will use
Tools for this app
In this place we’re gonna talk about Object Library where you can find many tools to work in storyBoard such as button, textLabel, Switch, etc. But the simplest thing you need to know first is what the IBOutlet and IBAction is
- IBOutlet (Interface Builder outlet) is a variable which is a reference to a UI component(user interface component).
- IBAction (Interface Builder action) is a function which is called when a specific user interaction occurs.
When you interact with the object and want them to do something, then you create an IBAction and define the work inside of it. But if you want to manipulate button’s appearance (change its title, round its corners, change its colour, add a border, or hide it), then you need an IBOutlet.
When you link design with code >> there are two things you need to know and set for making Connection
1. Connection
- Two types >> outlet/action >> It defines IBOutlet and IBAction
2. Name
- this is the important one >> you need to set the good Name relating to that function for understanding easily
Object Library Tools:
>> Label or textField
labelName.text = "string in this double quote show on screen"
textFieldName.text = "get or set string to textField"
>> ImageView > to set imageView in code
imageName.image = UIImage(named: "string must be name of pic")
>> Using Sender > if you take many objects in one IBAction, you can use sender.tag to know which one is pressed
if (sender.tag == the tag number you set first) {
// do whatever you want here
}
>> Switch button
@IBAction func clickSwitch(_ sender: Any) {
if (switchSwitch.isOn) {
// do anything you want when switch on
} else {
// do anything you want when switch off
}
}
>> Using Segue and Passing data between VC
// set button to linkto nextViewController
// set segue IdentifierName
// create new ViewController File by Cocoa Touch File
// link new viewController design to new vc file
// set performSegue and sender >> self (who pass) @IBAction func goToNextViewController(_ sender: Any) {
performSegue(withIdentifier: "Identifier", sender: self)
}
>> Randomisation from Array
let index = Int(arc4random_uniform(UInt32(array.count)))// may be you can create extension Array
extension Array {
func getRandomElement() -> Element? {
let index = Int(arc4random_uniform(UInt32(self.count)))
return self[index]
}
}// or create func get random number
func createRandomNumber(number: Int) -> Int? {
return Int(arc4random_uniform(UInt32(number)))
}
Other Work Shop you can try for practicing
Hack IOS 1 > https://github.com/sunboyy/thinc-5th-hack-ios-tutorial-1
Hack IOS 2 > https://github.com/sunboyy/thinc-5th-hack-ios-tutorial-2
Skeletion PRoject > https://github.com/beesk135/Skeleton-Project