我应该用增量变量来实现这个问题,但是解决方案是什么?非常感谢.
输入循环“进入重复” – “进入功能”
var condition = true var userId = Int.random(1...1000) repeat { print("Into repeat") checkId(userId,completionHandler: { (success:Bool) -> () in if success { condition = false } else { userId = Int.random(1...1000) } }) } while condition func checkId(userId:Int,completionHandler: (success:Bool) -> ()) -> () { print("Into function") let query = PFUser.query() query!.whereKey("userId",equalTo: userId) query!.findObjectsInBackgroundWithBlock({ (object:[PFObject]?,error:NSError?) -> Void in if object!.isEmpty { completionHandler(success:false) } else { completionHandler(success:true) } }) }