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 3722464
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:54:51+00:00 2026-05-19T05:54:51+00:00

I was going through the AVCam project from WWDC and I’m curious about the

  • 0

I was going through the AVCam project from WWDC and I’m curious about the following code. I thought you were supposed to declare an object, then @property (nonatomic,retain), then synthesize.

The Demo code does it a little differently, I’ll post some code (just a sample), anyone know what this does and when you should use it? Can anyone explain its significance and when to use it?

    @interface AVCamCaptureManager : NSObject {
@private
    // Capture Session
    AVCaptureSession *_session;
    AVCaptureVideoOrientation _orientation;

    // Identifiers for connect/disconnect notifications
    id _deviceConnectedObserver;
    id _deviceDisconnectedObserver;
}

@property (nonatomic,readonly,retain) AVCaptureSession *session;
@property (nonatomic,assign) AVCaptureVideoOrientation orientation;
@property (nonatomic,readonly,retain) AVCaptureAudioChannel *audioChannel;
@property (nonatomic,assign) NSString *sessionPreset;

in the implementation file:

    @interface AVCamCaptureManager ()

@property (nonatomic,retain) AVCaptureSession *session;
@property (nonatomic,retain) AVCaptureDeviceInput *videoInput;
@property (nonatomic,retain) AVCaptureDeviceInput *audioInput;

@end

    @implementation AVCamCaptureManager

@synthesize session = _session;
@synthesize orientation = _orientation;
@dynamic audioChannel;
@dynamic sessionPreset;

@dynamic focusMode;


- (id) init
{
  • 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-19T05:54:52+00:00Added an answer on May 19, 2026 at 5:54 am
    @property (nonatomic,readonly,retain) AVCaptureSession *session;
    

    This is a property that is readonly externally. Internally, it will have a setter that retains the new value.

    @property (nonatomic,assign) AVCaptureVideoOrientation orientation;
    

    This is a property that does a simple assignment to store the new value (since you can’t -copy or -retain primitives).

    @property (nonatomic,readonly,retain) AVCaptureAudioChannel *audioChannel;
    

    This is a property that is readonly externally. Internally, it will have a setter that retains the new value.

    @property (nonatomic,assign) NSString *sessionPreset;
    

    This is a property that does a simple assignment to store the new string value. This is normally not a good idea, unless you’re only allowing pre-defined constants for the presets. When dealing with NSString properties, you generally want them to be copy unless you have a good reason against it.

    In the implementation file:

    @property (nonatomic,retain) AVCaptureSession *session;
    @property (nonatomic,retain) AVCaptureDeviceInput *videoInput;
    @property (nonatomic,retain) AVCaptureDeviceInput *audioInput;
    

    These are used in conjunction with the properties declared in the header, except now it’s readwrite. By declaring the version in the header as readonly, anyone using the class will not have access to the setSession: method. We re-declare this property internally so that we can have access to the setter (and the setter retains the new value). Also, if the property is not present in the header, the user won’t know it exists, but we’ll still be able to use it internally.

    @synthesize session = _session;
    @synthesize orientation = _orientation;
    

    This means you want the compiler to generate the appropriate setters and getters for the session and orientation properties, and that you want those properties to store their values in the _session and _orientation instance variables, respectively.

    @dynamic audioChannel;
    @dynamic sessionPreset;
    @dynamic focusMode;
    

    This means that the implementations for the setters and getters will be provided at runtime. You usually don’t use @dynamic properties yourself, other than the ones provided by the Core Data framework.

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

Sidebar

Related Questions

Going through Javascript documentation, I found the following two functions on a Javascript object
While going through Effective C++ (by Scott Meyers), I came across the following code
Going through K&R I saw the following code snippet of a function, strcopy, which
Going through some tutorials about sockets, I keep coming across code like that: while(true){
While going through university and from following the development of SO, I've heard a
Going through EASTL, I stumbled across a peculiar line of code. The following link
Just going through the sample Scala code on Scala website, but encountered an annoying
While going through a WP7.5 background transfer service policy, one can read the following:
While going through a Zend tutorial , I came across the following statement: Note
While going through one project, I have seen that the memory data is 8

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.