• 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: NSData to long
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData to long


  • Subject: Re: NSData to long
  • From: Bill Haller <email@hidden>
  • Date: Tue, 8 Apr 2003 08:48:15 -0400

Okay, now I understand the question.

// set up a test NSData that is 4 bytes long
NSData * theData = [NSData dataWithBytes:@"\0\0\0\0" length:4];
*(long unsigned *) [theData bytes] = 36;
NSLog(@"theData %@",theData); // yields : theData <00000024 >

// Cast the bytes to an unsigned long pointer, dereference, use format stuff
NSString * theString =
[NSString stringWithFormat:@"%u", *(long unsigned *)[theData bytes]];
NSLog(theString); // yields 36

- Bill Haller
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: NSData to long
  • Next by Date: Re: NSScanner baffling behaviour (scanString:intoString: doesn't work!)
  • Previous by thread: Re: NSData to long
  • Next by thread: Re: NSView setVisible: method -- NOT
  • Index(es):
    • Date
    • Thread