Converting uint16_t port to a NSString
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