• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Converting uint16_t port to a NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting uint16_t port to a NSString


  • Subject: Converting uint16_t port to a NSString
  • From: Alexander Hartner <email@hidden>
  • Date: Tue, 5 Jun 2007 09:13:17 +0100

I am trying to construct an NSString from a set of different component. For some reason I am having problems converting a uint16_t correctly. In my tests it should convert the value 58080 to "58080". On PPC this has worked correctly, but on intel it converts it to 57570. I figure is something I am doing wrong related to stringWithFormat. I already tried using %i, %u %hu, but they all see to produce the same result.

void resolveCallBackSelf (DNSServiceRef sdRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname, const char *hosttarget, uint16_t port, uint16_t txtLen, const char *txtRecord, void *context )
{
if (errorCode == kDNSServiceErr_NoError)
{
NSLog(@"FULLNAME : %s \n",fullname);
NSLog(@"HOST : %s \n",hosttarget);
NSLog(@"PORT : %i \n",port);
NSLog(@"TXT : %s \n",txtRecord);
...
NSString * endPointUrl = [NSString stringWithFormat:@"http://%s:%i/ addressBook",inet_ntoa(*( struct in_addr*)( host -> h_addr)),port];


Any suggestions on how to resolve this ?
Kind regards
Alex
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Converting uint16_t port to a NSString
      • From: Andrew Farmer <email@hidden>
  • Prev by Date: Re: Core Data app becomes a memory hog
  • Next by Date: Re: setting corner view
  • Previous by thread: Re: Core Data app becomes a memory hog
  • Next by thread: Re: Converting uint16_t port to a NSString
  • Index(es):
    • Date
    • Thread