Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 741279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:36:51+00:00 2026-05-14T08:36:51+00:00

How can I read the data from read stream in Objective-C? The code below

  • 0
  1. How can I read the data from read stream in Objective-C? The code below would give me how many bytes are read from stream, but how can I know what data is read from stream?

    CFIndex cf = CFReadStreameRead(Stream, buffer, length);
    
  2. How can I extract only the 1st 2bytes of data in the read stream in Objective-C? For example, if this is the data from stream:

    017MacApp
    

    1st byte has 0 in it, and 2nd byte has 17 in it.

    How do I extract 0 and 17 into byte array?

I know that the below code would give me back the byte array to int value.

((b[0] & 0xFF) << 8)+ (b[1] & 0xFF);

but how to put 0 into b[0] and 17 into b[1]?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:36:51+00:00Added an answer on May 14, 2026 at 8:36 am
    uint8_t buffer[2];
    CFIndex cf = CFReadStreamRead(Stream, buffer, 2);
    if (cf == 2)
    {
        uint8_t firstByte = buffer[0];
        uint8_t secondByte = buffer[1];
    }
    else
    {
        // cf == -1 => error, cf == 0 => end of file, cf == 1 => you need to call again to get the second byte
    }
    

    Here is the Apple doc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First of all, it's a really bad idea to use… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer If you are not dead set on using a listbox,… May 16, 2026 at 9:17 am
  • Editorial Team
    Editorial Team added an answer killproc will terminate programs in the process list which match… May 16, 2026 at 9:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm writing some quick code to try and extract data from an mp3 file
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I want to use libmms in an objective-c project. I've taken the project from
I am trying to create a generic class to write and read Objects to/from
I'm trying to use System.Runtime.InteropServices.ComTypes.IStream from C#, but I'm having some trouble. According to
I am reading data from an IPhone App that uses http POST to transfer
I am currently trying to port a .Net app to Objective C and Cocoa.
I'm creating a WCF service which I want to consume from a Java app.
I am writing a multi-threaded .Net application in which many callers need to concurrently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.