jeudi 12 février 2015

Strange behavior from Core Data in iOS swift app

This is iOS 8.1 and Swift on Xcode (latest GA release) with identical behavior on both simulator and a device.


I have three entities: Match, Score and Team. Each Match has two teams, team1 and team2. Score also has team1 and team2. Match has a 1x1 relationship with Score, the fields being bet and betFor respectively. Match is identified by its field matchNumber.


So I have the following (psuedo)-code:



match.bet = score
score.team1 = match.team1
score.team2 = match.team2
context.save(&err)
// Check if err is nil or not
match = Match.lookup(context, matchNumber)
// Try doing something with match.bet.team1 and it crashes


Basically an attempt to retrieve the information I just set comes back as nil.


I have tried several things, including returnsObjectsAsFault = false during the fetch etc. When I open the .sqlite file using sqlite3, I can see the entries being made. I tried using sql debug flag set to 3, but nothing jumped out. I am not saying that avenue is exhausted, but I definitely am.


Any thoughts on what could be going on here? I am stuck on this for quite some time and any thoughts would be appreciated.


Aucun commentaire:

Enregistrer un commentaire