mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Value of type 'AsynchronousDataTransaction' has no member 'Element' #20
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ScottWallace on GitHub (Nov 21, 2015).
I'm getting a build error of "Value of type 'AsynchronousDataTransaction' has no member 'Element'" on the use of importUniqueObjects, in the code below on the transaction.importUniqueObjects line:
The parameter sites: NSArray is the output from an Alamofire download, and is a mutable array of NSDictionary objects.
SiteEntity is, of course, an NSManagedObject, and is defined:
The SiteEntity is extended with the ImportableUniqueObject protocol as such:
I've scoured the source, but can't find any relevant line that would point to the problem. I'm using the latest OS X, XCode, Swift, CoreStore - everything's brand new, including the app I'm creating.
There's a great deal of power with importUniqueObjects, and I'm anxious to take advantage of it. Any help you could provide would be terrific. I'm happy to try a test build, provide additional information, whatever is needed.
Thanks for your help.
@JohnEstropia commented on GitHub (Nov 21, 2015):
@ScottWallace
The error message seems to hide the real cause, but I think it's because you have declared
but you are passing
siteswhich is anNSArrayto thesourceArrayargument. SinceImportSourceis declared as a dictionary, all you have to do is castsitesas so:@ScottWallace commented on GitHub (Nov 21, 2015):
That fixed it. Man, was that obscure. It's sure to come up for someone else, so I'm glad it's documented here.
Thanks for the quick response, and for such a great tool.
@ablair08 commented on GitHub (Jan 5, 2016):
Hi there, I am trying to implement CoreStore and have encountered the same issue. However the fix above does not appear to work. Is it possible a change has occurred to stop to working. I am using the most update versions of all software.
i have also tried swiftyjson as used here (https://developers.eure.jp/ios/couples-powered-by-corestore-en/). Would anyone have an example
Many thanks
@JoeMatt commented on GitHub (Jan 5, 2016):
Personally, I would avoid declaring variables as 'NSArray' or 'NSDictionary' in Swift code unless absolutely necessary.
If you really need a completely generic container you can use '[AnyObject]' or '[String:AnyObject]' respectively for NSArray and NSDictionary.
If you want to use the NS* methods on the Swift primitive storage types you can still do so eg;
They'll bridge to Objective-C as long as the 'MyType' is an NSObject subclass
You'll avoid these type of obscure errors when declaring initially as the built in Swift types as apposed to the NS* storage classes directly. Just my $.02
@ScottWallace commented on GitHub (Jan 5, 2016):
I'm using the latest 1.4.1 release, and it's still working correctly for me. I'll expand the example a bit to include the portion where I make the call to .saveSites, which is passed the JSON output from AlamoFire.
Don't know what else to say except it's working using this example. It's probably silly of me to cast as NSArray then later as [NSDictionary], but there's some legacy stuff here, so it is what it is.
@ScottWallace commented on GitHub (Jan 5, 2016):
@JohnEstropia Just wanted to add this, if you create a "Apps Using CoreStore" section to readme.md, it's now in production use for the 4.0.0 release of 63red.
https://itunes.apple.com/us/app/63red-conservative-news-reader/id972910669?mt=8
It greatly increased the speed of merging in new data, and has added greater stability to the app. I'd previously been using MDMCoreData, and this is a million miles better. Thanks for helping my customers by creating a great tool!
@JohnEstropia commented on GitHub (Jan 6, 2016):
@ablair08 Are you declaring your
ImportSourceas?
If so, you need to call the
.arrayValueproperty of theJSONvalue when passing tosourceArray:@JohnEstropia commented on GitHub (Jan 6, 2016):
@ScottWallace Thanks for the feedback! Glad to hear CoreStore helped you :)
I'll think about adding an "Apps Using ..." section. If I do, I'll include 63red. Thanks again!