Hey Brian,
I think my app is in a bad state when I fire load images. I apologise for the long reply here.
I tried your code and photos still repeated so I went back to break points in fetchUser() and fetchPosts() and discovered errors which I didn't notice earlier.
1) Fire fetchUser() and console shows uid unable to read data i.e. user is nil. which is odd. Error reads:
firebaseInstagram[4183:106220] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806)
2) Then I fire fetchPosts() breakpoint at
ref.observeSingleEvent(of: .value, with: { (snapshot) in
and I get this really long error:
firebaseInstagram[4245] <Error> [Firebase/Core][I-NET901017] <Firebase/Network/ERROR> Encounter network error. Code, error: -1200, Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x60800012e1a0>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806, NSErrorPeerCertificateChainKey=(
"<cert(0x7fa0d4824600) s: *.googleapis.com i: Google Internet Authority G2>",
"<cert(0x7fa0d4826000) s: Google Internet Authority G2 i: GeoTrust Global CA>",
"<cert(0x7fa0d481ee00) s: GeoTrust Global CA i: Equifax Secure Certificate Authority>"
), NSUnderlyingError=0x60000005f4d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x60800012e1a0>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806, kCFStreamPropertySSLPeerCertificates=(
"<cert(0x7fa0d4824600) s: *.googleapis.com i: Google Internet Authority G2>",
"<cert(0x7fa0d4826000) s: Google Internet Authority G2 i: GeoTrust Global CA>",
"<cert(0x7fa0d481ee00) s: GeoTrust Global CA i: Equifax Secure Certificate Authority>"
)}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorClientCertificateStateKey=0}
2017-05-26 14:04:39.900 firebaseInstagram[4245] <Error> [Firebase/Core][I-COR000020] Error posting to Clearcut: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x60800012e1a0>, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806, NSErrorPeerCertificateChainKey=(
"<cert(..) s: *.googleapis.com i: Google Internet Authority G2>",
"<cert(..) s: Google Internet Authority G2 i: GeoTrust Global CA>",
"<cert(..) s: GeoTrust Global CA i: Equifax Secure Certificate Authority>"
), NSUnderlyingError=0x60000005f4d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef:..>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9806, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9806, kCFStreamPropertySSLPeerCertificates=(
"<cert(..) s: *.googleapis.com i: Google Internet Authority G2>",
"<cert(..) s: Google Internet Authority G2 i: GeoTrust Global CA>",
"<cert(..) s: GeoTrust Global CA i: Equifax Secure Certificate Authority>"
)}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://play.googleapis.com/log, NSErrorFailingURLStringKey=https://play.googleapis.com/log, NSErrorClientCertificateStateKey=0}, with Status Code: 0
{
3) Finally when I fire through, all photos load with repeats.
So I'm not sure why I'm getting the SSL error?