Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dantastic

macrumors 6502a
Original poster
Jan 21, 2011
572
678
I have just started coming across this use of an @ notation instead of a proper type initializer. Being quite simply an @ I've not been able to google any more info about it.

What is is, I've found these

@15 -> creates a NSNumber
@[@"one", @"two", @three"] -> creates a NSArray

Do anyone know where to find a bit more documentation around this? what the full capabilities are and any drawbacks?
 
Thanks Matt!

That's super cool stuff I must say. Now I know what to do today! :rolleyes:
 
Used it on a parent NSMangedObject to access the child objects in an ordered one to many relationship. Makes dealing with model objects in the controller easier and cleaner.
 
Used it on a parent NSMangedObject to access the child objects in an ordered one to many relationship. Makes dealing with model objects in the controller easier and cleaner.

Cool. I'll have to bear that in mind.

To add subscripting support to array-like objects, you have to add objectAtIndexedSubscript: and setObject:atIndexedSubscript: methods to your class, right? Anything else that you need to do?

And what about support for dictionary subscripting? For those, I gather you implement objectForKeyedSubscript: and (for mutable dictionaries) setObject:forKeyedSubscript:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.