我有以下代码将对象设置为nil
,但未调用deinit
。我deinit
的身体print("deinit")
。但它从未被称为。
let dispatchGroup = dispatch_group_create()
retVal = NSMutableArray()
for index in 0..<users.count {
let dictionary:NSDictionary = users.objectAtIndex(index) as! NSDictionary
let userId = dictionary.getValueAsString("_id")
let currentUserId = AppDelegate.sharedDelegate().userId!
if userId != currentUserId {
dispatch_group_enter(dispatchGroup)
var userModelHandler:UserModelHandler? = UserModelHandler()
userModelHandler?.fetchUser(userId: userId!) { groupUserInfo in
if let group = group {
groupUserInfo.group = [group]
}
retVal?.addObject(groupUserInfo)
dispatch_group_leave(dispatchGroup)
}
userModelHandler = nil
}
}
dispatch_group_notify(dispatchGroup, dispatch_get_main_queue()) {
UserModelHandler.downloadUsersProfilePicture(retVal!, completionHandler:completionHandler)
}
func fetchUser(userId id:NSString, block:CompletionBlock?) {
self.block = block
let appDelegate = AppDelegate.sharedDelegate()
let userId = id as String
let token = appDelegate.token as! String
let userHanlder = UserHandler()
userHanlder.fetchUser(userId: userId, token: token, delegate: operationDelegate!)
}