저는 IOS 애플리케이션 개발을 처음 접했습니다.함수가 완료 될 때까지 viewWillAppear가 완료되지 않게하는 방법
viewWillAppear의 작업이 끝날 때까지 작업을 중단하려고합니다. 어떻게해야합니까? 여기
은 viewWillAppear의 :override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
checkFacts()
if reset != 0 {
print("removing all bird facts")
birdFacts.removeAll()
}
}
func checkFacts() {
let date = getDate()
var x: Bool = true
var ind: Int = 0
print("count is ", birdFacts.count)
while ind < birdFacts.count {
print("accessing each bird fact in checkFacts")
let imageAsset: CKAsset = birdFacts[ind].valueForKey("birdPicture") as! CKAsset
let image = UIImage(contentsOfFile: imageAsset.fileURL.path!)
print(image)
if image == nil {
if (birdFacts[ind].valueForKey("sortingDate") != nil){
print("replacing fact")
print("accessing the sortingDate of current fact in checkFacts")
let sdate = birdFacts[ind].valueForKey("sortingDate") as! NSNumber
replaceFact(sdate, index: ind)
}
/*else {
birdFacts.removeAll()
print("removing all bird facts")
}*/
}
ind = ind + 1
print(ind)
}
self.saveFacts()
let y = checkRepeatingFacts()
if y {
print("removing all facts")
birdFacts.removeAll()
//allprevFacts(date, olddate: 0)
}
}
checkFacts 참조 2 개 다른 기능을하지만, 나는 그들이 (그들이 내가 틀리지하지만 만약 내가 그들을에 추가합니다)
viewWillAppear 전에 완료해야하는 checkFacts입니까? –
예, checkFacts는 먼저 완료해야합니다. – Alex
viewWillAppear 함수가 끝나기 전에 완료됩니다 (checkFacts에서 호출되는 함수에서 비동기 작업이없는 경우). 그래서 내가 누락 된 것 같습니다. 원하지 않는다는 것을 의미합니까? checkFacts가 끝날 때까지 표시 할보기? –