firebase 실시간 데이터베이스를 사용하고 있으며 내 응용 프로그램의 일부에서 정상적으로 작동합니다. 나는 youtube 튜토리얼을 통해 collectionView를 사용자로 채 웁니다. NSDictionary를 사용하여 사진 URL과 사용자 이름을 가져 와서 모든 사용자의 컬렉션보기에 추가합니다. firebase 콘솔에서 직접 일부 사용자를 삭제했으며 이제는 한 명의 사용자 만 있습니다. 웬일인지 그것은 내가 삭제했던 사용자를 아직도 끌고있다. 이것은 collectionView 파일입니다.firebase가 데이터베이스에서 삭제 된 데이터를 검색하고 있습니다.
import UIKit
import FirebaseDatabase
private let reuseIdentifier = "UserSearchCell"
class UsersCollectionViewController: UICollectionViewController {
var usersDict = NSDictionary?()
var userNamesArray = [String]()
var userImagesArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
DataService.ds.REF_USERS.observeEventType(.Value, withBlock :{
(snapshot) in
self.usersDict = snapshot.value as? NSDictionary
for(userId,details) in self.usersDict!{
let img = details.objectForKey("profileThumbUrl") as! String
let name = details.objectForKey("username") as! String
self.userImagesArray.append(img)
self.userNamesArray.append(name)
self.collectionView?.reloadData()
}
})
self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
}
override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.userImagesArray.count
}
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! UserSearchCell
let imageUrl = NSURL(string:userImagesArray[indexPath.row])
let imageData = NSData(contentsOfURL: imageUrl!)
cell.userImage.image = UIImage(data:imageData!)
cell.userName.text = userNamesArray[indexPath.row]
return cell
}
}
이 항상 데이터베이스와 동기화하지 않나요? 이러한 삭제 된 사용자의 출처는 어디입니까? 또한 셀 코드를 포함하지 않은 이유는 그것이 모두 imageView 및 Label 액션을 선언했기 때문입니다. 전에도이 문제에 부딪 쳤지 만 기억이 안 좋았고 기억이 안되는 이유를 기억하지 못합니다.
시뮬레이터! 그들은 세계의 문제의 절반을 일으킨다 :) – Fattie
안녕하세요! 나는 이제 실제 장치에 이미 그런 문제가 발생했습니다. 그러나 캐시 firebase에 포함 시켰습니다 – Alexander
FIRDatabase.database() 기능을 사용하지 않으면 모든 것이 올바르게 작동합니다. PersistenceEnabled. 어쩌면 이것이 내 다른 질문에 대한 해답이 될지도 모른다. – Alexander