nghiaiosdev / Learning-Swift

Learning Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learning-Swift

Variable and Declare Variable

Variable

  • Int
  • Float
  • Double
  • String
  • Character
  • Dictionary
  • Array
  • Set

Declare Variable

var numberIntA: Int = 10
var numberFloatB: Float = 34.3
var numberDecimaC: Double = 434343434343
var str: String = "Hello World"

let PI = 3.14
//Array
var arrNumberA: [Int] = [3, 5, 4, 6, 7, 8]
var arrNumberB: [Int]= [Int]()

var strNameA: [String] = ["Nghia", "Minh", "Phu", "Phuc"]
var strNameB: [String] = [String]()


//Dictionary
var dicA: [String: String] = [String: String]()
var dicB: [String: Int] = ["One: 1, "Two": 2, "Three": 3]

Permission in iOS

Full List:

Apple Music:

<key>NSAppleMusicUsageDescription</key>
<string>My description about why I need this capability</string>
Bluetooth:

<key>NSBluetoothPeripheralUsageDescription</key>  
<string>My description about why I need this capability</string>
Calendar:

<key>NSCalendarsUsageDescription</key>
<string>My description about why I need this capability</string>
Camera:

<key>NSCameraUsageDescription</key>
<string>My description about why I need this capability</string>
Contacts:

<key>NSContactsUsageDescription</key>
<string>My description about why I need this capability</string>
Health Share:

<key>NSHealthShareUsageDescription</key>
<string>My description about why I need this capability</string>
Health Update:

<key>NSHealthUpdateUsageDescription</key>
<string>My description about why I need this capability</string>
Home Kit:

<key>NSHomeKitUsageDescription</key>
<string>My description about why I need this capability</string>
Location:

<key>NSLocationUsageDescription</key>
<string>My description about why I need this capability</string>
Location (Always):

<key>NSLocationAlwaysUsageDescription</key>
<string>My description about why I need this capability</string>
Location (When in use):

<key>NSLocationWhenInUseUsageDescription</key>
<string>My description about why I need this capability</string>
Microphone:

<key>NSMicrophoneUsageDescription</key>
<string>My description about why I need this capability</string>
Motion (Accelerometer):

<key>NSMotionUsageDescription</key>
<string>My description about why I need this capability</string>
Photo Library:

<key>NSPhotoLibraryUsageDescription</key>
<string>My description about why I need this capability</string>
Reminders:

<key>NSRemindersUsageDescription</key>
<string>My description about why I need this capability</string>
Siri:

<key>NSSiriUsageDescription</key>
<string>My description about why I need this capability</string>
Speech Recognition:

<key>NSSpeechRecognitionUsageDescription</key>
<string>My description about why I need this capability</string>

AlertView iOS

let alertView = UIAlertController(title: "title", message: "Message", preferredStyle: .actionSheet)
        
        alertView.addAction(UIAlertAction(title: "OK", style: .default, handler: { (ac) in
            print("OK")
        }))
        
        alertView.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (ac) in
            print("Cancle")
        }))
        
//        alertView.addAction(UIAlertAction(title: "Normal", style: .destructive, handler: { (ac) in
//            print("Normal")
//        }))
        
        self.present(alertView, animated: true) {
            print("Saved")
        }

About

Learning Swift