Search code examples
iphoneobjective-cintunsigned

How do I convert from int to unsigned short int - iPhone


I am trying to get an integer from a plist and use it with sin_port. However sin_port requires an unsigned short and not an int how do I convert an int to an unsigned short int?


Solution

  • I don't know objective-c but in plain C you can do something like

    int value = 1234;
    unsigned short sin_port = (unsigned short) value;