• 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
int to bytes(value in NSString)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

int to bytes(value in NSString)


  • Subject: int to bytes(value in NSString)
  • From: bosco fdo <email@hidden>
  • Date: Mon, 17 Aug 2009 15:07:43 +0800

  Hi I dont understand of the below case of converting int to byte , the
below java code can able to print the byte value as below

System.out.println("binary output ::: "+Byte.toString(bo[0]));
System.out.println("binary output ::: "+Byte.valueOf(bo[1]));
System.out.println("binary output ::: "+Byte.valueOf(bo[2]));
System.out.println("binary output ::: "+Byte.valueOf(bo[3]));
System.out.println("binary output ::: "+new String(bo));

binary output ::: 0
binary output ::: 0
binary output ::: 0
binary output ::: 1
binary output ::: squaresquaresquaresquare ( 4 square chars) - binary data

but when i make a objective-c code to the same data into final NSString it
also prints as "0001" but not in binary format ( 4 square chars)

I need NSString in binary format how do i print NSString in binary format
instead of "0001"
  obj-c code is uint8 barr[4];
barr[0] =(uint8)num;
barr[1] =(uint8)num>>8;
barr[2] =(uint8)num>>16;
barr[3] =(uint8)num>>24;

i am using [NSString stringwithFormat:@%i,barr[i]]

which %? i need to use to get the byte value(binary data) as it is from the
array?

please help
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: int to bytes(value in NSString)
      • From: Graham Cox <email@hidden>
  • Prev by Date: Overriding NSCollectionView's selection: a good idea?
  • Next by Date: How to manage NSArray, NSDictionary, ... description encoding for non ascii characters?
  • Previous by thread: Re: Overriding NSCollectionView's selection: a good idea?
  • Next by thread: Re: int to bytes(value in NSString)
  • Index(es):
    • Date
    • Thread