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

  • SEARCH
  • Home
  • 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 6838207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:34:09+00:00 2026-05-26T23:34:09+00:00

In my iPhone app, I am using structure and access it from Objective C

  • 0

In my iPhone app, I am using structure and access it from Objective C UIViewController class, In one of my AudioInput.h file, I have the below:

   typedef struct
    {
        AudioStreamBasicDescription format;
        AudioQueueRef queue;
        AudioQueueBufferRef buffers[ NUM_AUDIO_BUFFERS ];
        SampleBuffer samples;
        bool running;
        bool done;

        UInt32 playPos;

    }   AudioRecording;

In My ViewController MainViewController.m I implemented the AudioInputCallback() as below:

static void AudioInputCallback(
    void *userData,
    AudioQueueRef queue,
    AudioQueueBufferRef buffer,
    const AudioTimeStamp *startTime,
    UInt32 numPackets,
    const AudioStreamPacketDescription *packetDescriptions
)
{
    // TRACE( "AudioInputCallback\n" );

    MainViewController *controller = (MainViewController *) userData;
    AudioRecording *audioRecording = & controller->audioRecording;

    if( audioRecording->done )
    {
        TRACE( "AudioInputCallback: done\n" );
        return;
    }
    if( numPackets == 0 && audioRecording->format.mBytesPerPacket > 0 )
    {
        numPackets = buffer->mAudioDataByteSize / audioRecording->format.mBytesPerPacket;
    }
    if( numPackets == 0 )
    {
        TRACE( "not packets received\n" );
        return;
    }

    const SInt16 *inSamples = (const SInt16 *) buffer->mAudioData;
    const UInt32 remain = audioRecording->samples.size - audioRecording->samples.count;
    if( numPackets > remain )
    {
        numPackets = remain;
    }
    if( numPackets == 0 )
    {
        TRACE( "AudioInputCallback: no packets received\n" );
    }
    if( numPackets > 0 )
    {
        /*  Save samples.  */
        if( audioRecording->samples.data )
        {
            UInt16 *in = (UInt16 *) inSamples;
            UInt16 *out = (UInt16 *)( audioRecording->samples.data + audioRecording->samples.count );
            for( UInt32 i = 0; i < numPackets; ++i )
            {
                *out ++ = ntohs( *in++ );
            }
        }
        audioRecording->samples.count += numPackets;
    }

    if( audioRecording->samples.count < audioRecording->samples.size )
    {
        OSStatus result = AudioQueueEnqueueBuffer( queue, buffer, 0, NULL );
        if( result )
        {
            TRACE( "AudioQueueEnqueueBuffer(..) failed with status %d\n", result );
        }
    }
    else
    {
        TRACE( "AudioInputCallback: enough material, stop recording\n" );
        audioRecording->done = true;
        AudioQueueStop( audioRecording->queue, true );
    }

    [controller performSelectorOnMainThread:@selector(bufferFilled) withObject:nil waitUntilDone:NO];
}

In this method on the below line It gives error as “instance variable is protected”

MainViewController *controller = (MainViewController *) userData;
AudioRecording *audioRecording = & controller->audioRecording;

This error is occurs while running for iOS 5 with XCode 4.2 but the same code is running without any error building for below iOS 5 in XCode 4.0.2.

Can anyone help me why this error occurs? and your ideas to solve this is welcome!

  • 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-26T23:34:09+00:00Added an answer on May 26, 2026 at 11:34 pm

    It’s nothing to do with your structure, it’s to do with how you’ve defined the members of your UIViewController subclass. Take a look at this :

    @interface MainViewController : UIViewController
    {
    @public
        AudioRecording audioRecording1;
    
    @protected // This is the default
        AudioRecording audioRecording2;
    
    @private
        AudioRecording audioRecording3;
    }
    @end
    

    Here, this controller has three AudioRecording members. However, only audiorecording1 can be access directly from outside the class. audiorecording3 cannot be accessed by anything other than the MainViewController and audiorecording2 can be accessed by MainViewController and any subclasses of it.

    You need to make your audiorecording public if you want to access it directly without going though an accessor method (or a property).

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

Sidebar

Related Questions

I'm working on an iPhone app using objective C. I've got class A, which
I have an iPhone app using a UINavigationController. On the fourth controller of the
I have developed an iPhone app using an iPhone 3G. How can I test
I am working on an iPhone app using a SQLite db. I have some
I'm programming an iPhone app using Objective-C. Here's the error Xcode gives me: error:
I have an iphone app using ASIHttpRequest. The server code is on heroku in
I have an iPhone app using these (via UIAccelerometer) - will it work on
I have created a small iPhone app using MonoTouch - got all provisioning files
I have inherited code for an iPhone app using Core Data written by another
im developing an iphone app using yahoo weather service ( i have a key

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.