Originally created by @akac on GitHub (Aug 11, 2017).
I am trying to simply get an object that I have an NSManagedObjectID for:
let event = dataStack.fetchExisting<AVXCheckinEvent>(checkinEventID)
I get the error:
Cannot specialize a non-generic definition
Of course if I use a perform sync: let event = try! DataStore.shared.dataStack.perform(synchronous: { (transaction) -> AVXCheckinEvent? in return transaction.fetchExisting(checkinEventID) })
it works fine - but obviously I'd like to understand better why the simpler method which seems should work - does not.
Originally created by @akac on GitHub (Aug 11, 2017).
I am trying to simply get an object that I have an NSManagedObjectID for:
`let event = dataStack.fetchExisting<AVXCheckinEvent>(checkinEventID)`
I get the error:
> Cannot specialize a non-generic definition
Of course if I use a perform sync:
` let event = try! DataStore.shared.dataStack.perform(synchronous: { (transaction) -> AVXCheckinEvent? in
return transaction.fetchExisting(checkinEventID)
})
`
it works fine - but obviously I'd like to understand better why the simpler method which seems should work - does not.
Right - I tried that first :) I can't make it work in any fashion at all.
So let event = dataStack.fetchExisting(checkinEventID) tells me that
Expression type '_?' is ambiguous without more context
Another example of the problems I'm seeing:
dataStack.perform(asynchronous: { (transaction) in let result = transaction.create(Into<AVXCheckinEventResult>()) let event = transaction.fetchExisting(checkinObjectID)
This is a one to many - where I need to add results to the event. I've got an ObjectID - but in the above I get:
Expression type '_?' is ambiguous without more context
in the first line and
Ambiguous reference to member 'fetchExisting'
on the fetchExisting.
I'm pulling my hair out to do what should be really simple stuff - create an object, get another object and add the relationship. I don't know if its a Swift issue, or if I'm just not understanding something basic in Swift generics.
Since its past midnight here - I forgot to add - I'm on Swift 3.2.
@akac commented on GitHub (Aug 11, 2017):
Right - I tried that first :) I can't make it work in any fashion at all.
So `let event = dataStack.fetchExisting(checkinEventID)` tells me that
> Expression type '_?' is ambiguous without more context
Another example of the problems I'm seeing:
` dataStack.perform(asynchronous: { (transaction) in
let result = transaction.create(Into<AVXCheckinEventResult>())
let event = transaction.fetchExisting(checkinObjectID)
`
This is a one to many - where I need to add results to the event. I've got an ObjectID - but in the above I get:
> Expression type '_?' is ambiguous without more context
in the first line and
> Ambiguous reference to member 'fetchExisting'
on the fetchExisting.
I'm pulling my hair out to do what should be really simple stuff - create an object, get another object and add the relationship. I don't know if its a Swift issue, or if I'm just not understanding something basic in Swift generics.
Since its past midnight here - I forgot to add - I'm on Swift 3.2.
I should add - the reason I'm using objectIDs is that I am having an issue where I have an object - AVXCheckinEvent - and I'm adding results to it via asynchronous transactions. At the very end - I need to enumerate the results for that event. On that final step, the relationship is nil on the object. Yet, when I print out all the values at all the steps - the relationship data is there and of course its there in the database. So my guess is that the object is in a different context and not merged/refreshed or something. I'm not sure, I don't know how CoreStore works internally so I'm not sure if something is being cached. So I'm trying to simply fetch the event object at every step instead of holding on to it.
I've been working with CoreData for 7 years, but I had a ton of Objective-C wrappers for my code and in general I've been away from CD for about 9 months now, so I'm rusty.
@akac commented on GitHub (Aug 11, 2017):
I should add - the reason I'm using objectIDs is that I am having an issue where I have an object - AVXCheckinEvent - and I'm adding results to it via asynchronous transactions. At the very end - I need to enumerate the results for that event. On that final step, the relationship is _nil_ on the object. Yet, when I print out all the values at all the steps - the relationship data *is* there and of course its there in the database. So my guess is that the object is in a different context and not merged/refreshed or something. I'm not sure, I don't know how CoreStore works internally so I'm not sure if something is being cached. So I'm trying to simply fetch the event object at every step instead of holding on to it.
I've been working with CoreData for 7 years, but I had a ton of Objective-C wrappers for my code and in general I've been away from CD for about 9 months now, so I'm _rusty_.
OK I was able to result the fetch. I rarely ever annotate a variable with its type and just use type inference. It hit me… let event : AVXCheckinEvent = dataStack.fetchExisting(checkinEventID)
worked.
@akac commented on GitHub (Aug 11, 2017):
OK I was able to result the fetch. I rarely ever annotate a variable with its type and just use type inference. It hit me…
`let event : AVXCheckinEvent = dataStack.fetchExisting(checkinEventID)`
worked.
Ah, sorry for the late reply. Yeah this overload needs an explicit type for the return value. Maybe I'll add an overload that accepts the type as an argument.
@JohnEstropia commented on GitHub (Aug 11, 2017):
Ah, sorry for the late reply. Yeah this overload needs an explicit type for the return value. Maybe I'll add an overload that accepts the type as an argument.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @akac on GitHub (Aug 11, 2017).
I am trying to simply get an object that I have an NSManagedObjectID for:
let event = dataStack.fetchExisting<AVXCheckinEvent>(checkinEventID)I get the error:
Of course if I use a perform sync:
let event = try! DataStore.shared.dataStack.perform(synchronous: { (transaction) -> AVXCheckinEvent? in return transaction.fetchExisting(checkinEventID) })it works fine - but obviously I'd like to understand better why the simpler method which seems should work - does not.
@sidmani commented on GitHub (Aug 11, 2017):
fetchExisting isn't a generic function- remove the <AVXCheckinEvent> and it should work.
@akac commented on GitHub (Aug 11, 2017):
Right - I tried that first :) I can't make it work in any fashion at all.
So
let event = dataStack.fetchExisting(checkinEventID)tells me thatAnother example of the problems I'm seeing:
dataStack.perform(asynchronous: { (transaction) in let result = transaction.create(Into<AVXCheckinEventResult>()) let event = transaction.fetchExisting(checkinObjectID)This is a one to many - where I need to add results to the event. I've got an ObjectID - but in the above I get:
I'm pulling my hair out to do what should be really simple stuff - create an object, get another object and add the relationship. I don't know if its a Swift issue, or if I'm just not understanding something basic in Swift generics.
Since its past midnight here - I forgot to add - I'm on Swift 3.2.
@akac commented on GitHub (Aug 11, 2017):
I should add - the reason I'm using objectIDs is that I am having an issue where I have an object - AVXCheckinEvent - and I'm adding results to it via asynchronous transactions. At the very end - I need to enumerate the results for that event. On that final step, the relationship is nil on the object. Yet, when I print out all the values at all the steps - the relationship data is there and of course its there in the database. So my guess is that the object is in a different context and not merged/refreshed or something. I'm not sure, I don't know how CoreStore works internally so I'm not sure if something is being cached. So I'm trying to simply fetch the event object at every step instead of holding on to it.
I've been working with CoreData for 7 years, but I had a ton of Objective-C wrappers for my code and in general I've been away from CD for about 9 months now, so I'm rusty.
@akac commented on GitHub (Aug 11, 2017):
OK I was able to result the fetch. I rarely ever annotate a variable with its type and just use type inference. It hit me…
let event : AVXCheckinEvent = dataStack.fetchExisting(checkinEventID)worked.
@JohnEstropia commented on GitHub (Aug 11, 2017):
Ah, sorry for the late reply. Yeah this overload needs an explicit type for the return value. Maybe I'll add an overload that accepts the type as an argument.