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

chrono1081

macrumors G3
Original poster
Jan 26, 2008
8,772
5,420
Isla Nublar
Hi guys,

I noticed Xcode now corrects -
Code:
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

to
Code:
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

I have never seen the <UITouch *> part before in Objective-C. Can anyone explain what exactly that syntax is doing? It seems to work fine without it but I'd like to know what it is. Searching didn't bring up anything on the topic.
 
Last edited by a moderator:
It's called 'objective c generics' It allows classes, usually container classes, to be specialized for a type other than id.

The <sometype*> syntax is common among a number of programming languages, like swift, Java, C++ and others.
 
  • Like
Reactions: chrono1081
It's called 'objective c generics' It allows classes, usually container classes, to be specialized for a type other than id.

The <sometype*> syntax is common among a number of programming languages, like swift, Java, C++ and others.


Thanks! I've seen it in C++ but never in Objective-C and thought maybe that's what it was, but I couldn't find an answer on it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.