• 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: Reading from an NSInputStream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading from an NSInputStream


  • Subject: Re: Reading from an NSInputStream
  • From: Troy Dawson <email@hidden>
  • Date: Sat, 22 Nov 2003 09:03:03 -0800

> uint8_t *buf;
> unsigned int *numBytes;
> [stream getBuffer:&buf length:numBytes];
> for (int i = 0; i < *numBytes; i++) {
> printf("%c", buf[i]);
> }
> }
> }
>
> Once the code hits here, however, the application receives signal 11
> underneath the [inputStream getBuffer:&buf length:numBytes] call, in
> Apple's code.
>
> I imagine I'm doing something drastically wrong here, but I can't for
> the life of me figure out what it is. Any help would be greatly
> appreciated.

I think you want the -read method:

// reads up to length bytes into the supplied buffer, which must be at
least of size len. Returns the actual number of bytes read.

the -getBuffer method has the following comment:

// returns in O(1) a pointer to the buffer in 'buffer' and by
reference in 'len' how many bytes are available. This buffer is only
valid until the next stream operation. Subclassers may return NO for
this if it is not appropriate for the stream type. This may return NO
if the buffer is not available.

you're not checking the return of getBuffer, which can and will return
NO if it doesn't like you.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Reading from an NSInputStream
      • From: Evan DiBiase <email@hidden>
References: 
 >Reading from an NSInputStream (From: Evan DiBiase <email@hidden>)

  • Prev by Date: AppleScript Integration
  • Next by Date: KeyDown events in a ComboBox the 2nd
  • Previous by thread: Reading from an NSInputStream
  • Next by thread: Re: Reading from an NSInputStream
  • Index(es):
    • Date
    • Thread