• 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
Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare


  • Subject: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
  • From: Adam Venturella <email@hidden>
  • Date: Mon, 26 Jan 2009 19:09:12 -0800

Here is what I am doing now.. I just feel like I have an extra step in
converting the buffer into NSData...malloc...free

uint sample = 0x04034b50;
uint8_t buffer[sizeof(uint)];

[inputStream open];
[inputStream read: buffer maxLength:sizeof(buffer)];

NSData * d = [NSData dataWithBytes:buffer length:sizeof(buffer)];
uint * key = (uint *) malloc(sizeof(uint));
[d getBytes:key length:sizeof(uint)];

[inputStream close];

NSLog(@"%u = %u", *key, sample);

free(key);
_______________________________________________

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: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Properties and memory management with overrides.
  • Next by Date: Re: Not Resolving Aliases
  • Previous by thread: Re: CoreData silently failing to insert?
  • Next by thread: Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
  • Index(es):
    • Date
    • Thread