var LocalFile = "xxx.json"
var Delta = false
var priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
init(){
priority = DISPATCH_QUEUE_PRIORITY_HIGH
}
init(_:Bool){
Delta = true
priority = DISPATCH_QUEUE_PRIORITY_LOW
}
func getList(postData: Dictionary<String, String>){
let localdata = readfile(LocalFile)
if (localdata != "" && Delta == false){}
else{
}
}
I am just a beginner for learning Swift. When I look through this class, I wonder why this class contains 2 init()
? How does it work with "priority"?
init(){
priority = DISPATCH_QUEUE_PRIORITY_HIGH
}
default
constructor. It means your instance variable will be initialized by default with their respective values. Here the priority is HIGH (DISPATCH_QUEUE_PRIORITY_HIGH)
init(_:Bool){
Delta = true
priority = DISPATCH_QUEUE_PRIORITY_LOW
}
1 . It is parameterised
, constructor. It means you are initializing Delta while you are creating object of this class.
2 . Here the priority is LOW (DISPATCH_QUEUE_PRIORITY_LOW)