New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native Swift Set in Swift template (Swift 1.2) #266
Comments
Created a pull request that uses Swift 1.2 Set objects. This is just a suggestion and might not be the way you want to solve Swift 1.2 support. |
As a set does not keep the order of the objects in the same way, it might even be nicer to use an Array? This might be worth a little discussion? |
@depl0y Generally speaking order of objects in Array will be random, because source is always a Set |
Yup, I think using a NSOrderedSet would be hard, because there is no way to specify in the model editor, that you want an ordered set. I forgot about the uniqueness, yes, so an Array is out of the question and just using the |
@depl0y actually there is! ;) review model editor for to-many relationship one more time. There is a "ordered" checkmark. |
Ah yes, but it seems that Swift does not (yet) support the OrderedSet.
The current Swift template does not use that setting either (because of the lack of support for the ordered set maybe, although the current template uses The current implementation for |
Ok, so I had a small discussion with somebody from Apple about the use of NSSet/Set to fill an UITableView. The person from Apple said it wouldn't be advisable to use a Set directly, because of it's inefficiency while iterating over it. So, it is probably better to cast it to an Array before doing that, but I am wondering what the reason is that we use a Set here, instead of an Array (seriously, I don't know). |
Hi, Can it be that this issue: magicalpanda/MagicalRecord#963 related to using Set vs Array? I am currently using template from #267. |
MagicalPanda issue was not related to this. |
I don't believe Core Data can handle swift native sets yet? Can someone point me to docs proving me wrong? I'd love to integrate them if its possible in Swift 2.0. |
This is my project which using Core Data integrated with Swift 2.0 native Set. The feature is first available in Swift 1.2. 发送自 Outlook Mobile On Sat, Dec 26, 2015 at 8:48 AM -0800, "Justin Williams" notifications@github.com wrote: I don't believe Core Data can handle swift native sets yet? Can someone point me to docs proving me wrong? I'd love to integrate them if its possible in Swift 2.0. — |
We are declaring pull request and issue 0 now that 1.3 is out. If this is still an issue you'd like to see address with 1.30 and going forward, please open a new issue so we can start a fresh discussion. Thank you! |
I am thinking about creating a pull-request to get mogenerator to work with Swift 1.2, since Swift 1.2 supports sets natively.
Only I am not really sure if the way I want to do it is the way it should be solved.
Currently the one-to-many relationships are defined as:
and there is a
addMyObjects(objects: NSSet)
method implemented like this:I was taking a look at the new Swift 1.2 specs and it seems that we can now do:
and implement the
addMyObjects
method like this:As you can see, I removed the whole mutableCopy part, but I am not sure this is the way we should actually fix this for Swift 1.2.
I didn't use a
let
because the@NSManaged
tag isn't allowed on that.The text was updated successfully, but these errors were encountered: