Group Group Group Group Group Group Group Group Group

Chapter 3, converting the relationship to unordered set (NSSet)

#1

Hello;

The Note on page 78 states that if the walks relationship was unordered one could set the “one” side of the relationship via the following code in the “add” function:

walk.dog = currentDog

I’ve done so (after commenting out the NSMutableOrderedSet and NSOrderedSet lines) and now the following line of code in cellForRowAtIndexPath fails:

let walk = currentDog.walks![indexPath.row] as! Walk

because “Type NSSet has no subscript members”, which makes sense. What would cellForRowAtIndexPath (and any other applicable function) look like in the case of an unordered relationship?

TIA

1 Like
#2

Bumping this because I have the same question. From what I have read, it is very rare to need to use NSOrderedSet, so it is strange that they would use that in the example.

#3

Did anyone ever figure out why this happens?

#4

@pietrorea Can you please help with this when you get a chance? Thank you - much appreciated! :]