• 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
Re: NSString to bit pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString to bit pattern


  • Subject: Re: NSString to bit pattern
  • From: Greg Guerin <email@hidden>
  • Date: Fri, 8 May 2009 08:47:19 -0700

erappy wrote:

Hi, I am trying to find way to convert the NSString object into its bit
pattern and convert that bit pattern into another NSString object,
For Example if I have
NSString *origStr = @"Hello":
NSString * bitPatternoforigStr ;
no I want to convert it to the bit pattern if Hello and return an object of
type NSString with bit pattern.
it should be something like;
bitPatternoforigStr = @"0101101001100010010011111000010101100101" ;
Can someone help me in this.

Break it down.

A string is a sequence of characters. Retrieve each character, determine its bit-pattern, then append that pattern to an NSMutableString. Now you have to figure out how to turn a character into its bit-pattern. So break that down.

A character (or any simple non-floating type) is a sequence of bits. If you know the C operators for Boolean AND and SHIFTS (& and >> and <<), then you know enough to isolate single bits from a character. Then you just test each bit and append either a '0' or '1' character to the accumulating NSMutableString.

  -- GG

_______________________________________________

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: NSString to bit pattern
      • From: Andrew Farmer <email@hidden>
  • Prev by Date: Re: Converting NSString to C++ std::string
  • Next by Date: Re: Converting NSString to C++ std::string
  • Previous by thread: Re: NSString to bit pattern
  • Next by thread: Re: NSString to bit pattern
  • Index(es):
    • Date
    • Thread