Sei sulla pagina 1di 4

Guard

It is used as it makes the code more easy and clear


It is used in the place of “if let”
It minimises the the complex code into more transparent and
easy to understand
As guard is used to validate the UItextField and it unwraps the
data
It has the default value as string
guard let first = txtFname.text, txtFname.text?.count != 0

isSelected
it is used when the clicked event is performed, to know the that click hav
isSelected can carry only bool value
button.isSelected = false

setImage
It is used to set the image to the button dynamically.
The image can be change only if we take the outlet of that button
btnChk.setImage(UIImage(named: "checkbox_unfill"), for: .normal)

UIAlertController
It has two types one is .alert and another is .actionsheet
As .alert comes in the middle of the screen as the pop up
and .actionsheet come at the bottom of the screen but above
the safe area.
In alert we can use the button, textfield and the message to be
displayed
let alert = UIAlertController(title: "Error", message: "Enter Valid
Phone Number", preferredStyle: .alert)
let alert = UIAlertController(title: "Note", message: "Your Data Have
Been Submitted", preferredStyle: .actionSheet)

NotificationCenter
In Notification Centre one how listens the notification is called as the
observer.
It itself keeps the track of the notifications and the observer.
The first parameter in it is always unnamed as it is always the self
The second parameter is the function which we want to call ie.the
target where we want to perform
Third parameter is the notification name and the name of the
listener.
Forth parameter is optional as if we want the notification or not and
it is sent by the sender
NotificationCenter.default.addObserver(self, selector:
#selector(keyboardWillShow), name:
UIResponder.keyboardWillShowNotification, object: nil)

contentInset
It is used to make the scroll view fit in the screen
It does not compress the screen as it takes the screen on the the
upper side when the keyword appears
It makes the counting from where the keyboard appears as the view
can be scrolled till the top most bond of the keyboard
scrollView.contentInset.bottom = 0

keyboardFrameEndUserInfoKey
It is used for as if we touch outside the keyboard the keyboard will
disappear

TabBar Controller
It is used open multiple pages one at a time on just one tap
For that we can gives the images and the the title for the same
As image should be of 25x25, 50x50, 75x75 to fit in the TabBar as
per the requirement
As in tab bar we can select multiple views by adding n numbers of
viewcontrollers

#pragma mark (objective C)


It is used for categorising the methods used in the project, so we
can find it easily.
It has no impact on the code

//MARK: (Swift)
It is used for categorising the methods used and mark in the
project, so we can find it easily.
It has no impact on the code

Format for writing the code


1. Outlets
2. Variables
3. Life cycles
4. Function Methods

Toolbar
It is used to perform the action into the current page and tab bar is
the next view controller var tab bar is used to perform action on the
current page

Affine Transform
It is a graphic coordinate transform
To degree the image affine transform in used

Outlets of different views


It is used for giving the height of the views dynamically
As height helps us to make the vale to the expected height of the
view, as it can be changed programatically.
Outlet : @IBOutlet weak var tbl1HeightLayout: NSLayoutConstraint!
Constraint : tbl1HeightLayout.constant =
tblView1.contentSize.height
textViewerHeight.constant = 0

numberOfSections in UItableView
It is used to give the sections in the the the table.
As the the section contains the the tableview cells.
One section can contain ’n’ numbers of cell in it

numberOfRowsInSection
As this method contains the number of rows in the section

viewForHeaderInSection
As this method works as the header in the section.
This Method is used so that we can give the header to the the
section in minimum time span.

tag
It is used to pass the information from cell to the Another
controller
It used for the button as when the the button is created but the
the action is not given.
cell.btnChk.tag = indexPath.row

addtarget
It is used to give the action to the target.
cell.btnChk.addTarget(self, action: #selector(self.pressed),
for: .touchUpInside)

UINib
UInib is to initiate the the custom cell which we will be creating
using the .xib file
This should be first initiated in the viewdidload() as this initiates the
the cell
For Table View Cell
tableView_Name.register(UINib(nibName: "Cell_Name”, bundle:
nil), forCellReuseIdentifier: "Cell_Identifier_Name")
For Collection View Cell
CollectionView_Name.register(UINib(nibName: "Cell_Name”,
bundle: nil), forCellWithReuseIdentifier: "Cell_Identifier_Name")

sizeForItemAt
This method is used in the collection view
This is used to give the size of the cell Dynamically

minimumLineSpacingForSectionAt
This is used for giving the space between the cells in the same
section.

Potrebbero piacerti anche