Can someone explain some syntax to me please? <UITouch *>

Discussion in 'iOS Programming' started by chrono1081, Jan 31, 2016.

  1. chrono1081, Jan 31, 2016
    Last edited by a moderator: Jan 31, 2016

    chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #1
    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.
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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.
     
  3. chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #3

    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.
     

Share This Page