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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:53:52+00:00 2026-05-30T00:53:52+00:00

Enrivonment: Mac OS X 10.6.8 Xcode 3.2.3 @interface A : NSObject @end @implementation: A

  • 0

Enrivonment: Mac OS X 10.6.8 Xcode 3.2.3

@interface A : NSObject
@end

@implementation: A
@end

@interface B : A
{
    int b;
}
@property int b;
@end

@implementation B
@synthesize b;
@end

#import "A.h"
#import "B.h"

int main()
{
    A *pa;
    pa = [[B alloc] init];
    pa.b = 3; /*here I get a error: request for member 'b' in something 
                not a structure or union. */

    [pa setB: 3]; // this works.
    return 0;
}

So why is that an error? As I know dot notation and bracket notation do the same thing.

  • 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-30T00:53:53+00:00Added an answer on May 30, 2026 at 12:53 am

    At runtime they do the same, yes, but you are still at compile time.

    At compile time, if you use dot notation the compiler doesn’t let you get away with something that it thinks might not work. Since you are accessing the object through the base class type A, but the property sits on type B, the compiler complains with an error.

    If on the other hand you use bracket notation, the compiler is less adamant and prints a warning only. It concedes that you might know what you are doing 🙂 but it lets you know that it hasn’t seen a method named setB: in the interface of class A.

    To get rid of the warning, declare your variable lke this:

    id pa;
    

    Using the type id (which translates as “pointer to an object”) lets you send any message to an object without a warning, because now the compiler makes no assumptions whatsoever about the object’s type. You have arrived in the wonderful world of the fully dynamic language Objective-C 🙂

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

Sidebar

Related Questions

if mono touch is available than why we should use mac environment(sdk,xcode+Interface Builder)? what
My environment: Mac OS X v10.7.2 with Xcode 4.2.1 I am trying to build
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
How do I get the command-line build tools installed with the current Xcode/Mac OS
As per the instructions here: http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/CoreAudioOverview/WhatisCoreAudio/WhatisCoreAudio.html#//apple_ref/doc/uid/TP40003577-CH3-SW1 It says: The Core Audio SDK assumes you
Found a similar post here but I am running a Mac so the first
complete Python noob here (and rusty in C). I am using a Mac with

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.