NSSortDescriptor key property?

In Challenge 2, it asks you sort the holdings by “current value in dollars.” I understand how I would ordinarily go about creating a sort descriptor, but there is currently no property (at least if I’m understanding this terminology correctly, in that it has to be one of the @property values or an instance variable set up manually) for this. I tried using “valueInDollars” as the key for the NSSortDescriptor, and the code built/ran, but nothing ended up getting sorted.

Are we supposed to add a new property to the BNRStockHolding class, or is there some way to make this work without doing so? Also, if I’m totally off-base in my interpretation of the word “property” here–which I’ll fully admit could well be the case–let me know.

EDIT: I appear to have been off-base! I messed up with some of the internals of my topThreeHoldings method, causing the sort to not change anything at all. But just to confirm, then, because the book doesn’t really make it clear, methods (presumably ones that return values) are valid “properties” when it comes to keys in NSSortDescriptors?

I had the same question after running the code on p. 184. It is possible to sort the array based on “valueOfAssets” even though this is an actual method call? Doesn’t make much sense but it works.

Yeah, I was unsure of exactly how those key values worked. As I understand it now, it will first search for a method of that name, and if it doesn’t find one, it will search for a property of that name. If it can’t find either, an exception will be thrown.