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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:47:05+00:00 2026-05-13T18:47:05+00:00

I’m trying to figure out if I can use dot syntax in objective c

  • 0

I’m trying to figure out if I can use dot syntax in objective c in order to access class variables.

For example if I have a class named ClassA of type NSObject.

ClassA has an instance of a class named ClassB also of type NSObject.

And ClassB has a variable named myString of type NSString;

In a view controller that has an instance of ClassA as a variable I’m trying to access “myString” by saying

NSString *aString=classA.classB.myString;

Which gives me this error

 error: accessing unknown 'myString' component of a property

if classB can be accessed with the dot syntax why can’t the string variable?

///////////added edit//////////

Sorry for the delay.
Also the comment box only allows so many characters so I had to use the anser box instead.

#import <Foundation/Foundation.h>

@class PromoTrackValueObject;
@class PromoMixValueObject;
@class PromoSkinValueObject;
@class EventsValueObject;
@class BuyValueObject;


@interface PromoValueObject : NSObject {
    NSString *promoXMLPath;
    NSString *type;
    NSString *username;
    NSString *entityname;
    NSString *userid;
    NSString *hasavatar;
    NSString *trackbuy_profile;
    NSString *bio;
    NSString *country;
    NSString *url_facebook;
    NSString *url_twitter;
    NSString *url_discog;
    NSString *url_myspace;
    NSString *url_chart;
    NSString *labelname;
    NSString *labelurl;
    NSString *labelimg;
    NSString *agent_name;
    NSString *agent_url;
    NSString *agent_img;
    NSString *promo_date;

    PromoTrackValueObject *promoTrack;
    PromoMixValueObject *promoMix;
    PromoSkinValueObject *promoSkin; // class containing string property in question is in here
    EventsValueObject *events;
    BuyValueObject *buy;



}

@property (nonatomic,copy)NSString *promoXMLPath;
@property (nonatomic,copy)NSString *type;
@property (nonatomic,copy)NSString *username;
@property (nonatomic,copy)NSString *entityname;
@property (nonatomic,copy)NSString *userid;
@property(nonatomic,copy)NSString *hasavatar;
@property (nonatomic,copy)NSString *trackbuy_profile;
@property(nonatomic,copy)NSString *bio;
@property(nonatomic,copy)NSString *country;
@property(nonatomic,copy)NSString *url_facebook;
@property(nonatomic,copy)NSString *url_twitter;
@property(nonatomic,copy)NSString *url_discog;
@property(nonatomic,copy)NSString *url_myspace;
@property(nonatomic,copy)NSString *url_chart;
@property(nonatomic,copy)NSString *labelname;
@property(nonatomic,copy)NSString *labelurl;
@property(nonatomic,copy)NSString *labelimg;
@property(nonatomic,copy)NSString *agent_name;
@property(nonatomic,copy)NSString *agent_url;
@property(nonatomic,copy)NSString *agent_img;
@property(nonatomic,copy)NSString *promo_date;

@property(nonatomic,retain)PromoTrackValueObject *promoTrack;
@property(nonatomic,retain)PromoMixValueObject *promoMix;
@property(nonatomic,retain)PromoSkinValueObject *promoSkin;
@property(nonatomic,retain)EventsValueObject *events;
@property(nonatomic,retain)BuyValueObject *buy;
@end


#import "PromoValueObject.h"
@implementation PromoValueObject
@synthesize promoXMLPath;
@synthesize type;
@synthesize username;
@synthesize entityname;
@synthesize userid;
@synthesize hasavatar;
@synthesize trackbuy_profile;
@synthesize bio;
@synthesize country;
@synthesize url_facebook;
@synthesize url_twitter;
@synthesize url_discog;
@synthesize url_myspace;
@synthesize url_chart;
@synthesize labelname;
@synthesize labelurl;
@synthesize labelimg;
@synthesize agent_name;
@synthesize agent_url;
@synthesize agent_img;
@synthesize promoMix;
@synthesize promoSkin;
@synthesize events;
@synthesize buy;
@synthesize promoTrack;
@synthesize promo_date;

- (void)dealloc {
    [promoTrack release];
    [promoMix release];
    [promoSkin release];
    [events release];
    [buy release];
   [promoXMLPath release];
    [type release];
    [username release];
    [entityname release];
    [userid release];
    [hasavatar release];
    [trackbuy_profile release];
    [bio release];
    [country release];
    [url_facebook release];
    [url_twitter release];
    [url_discog release];
    [url_chart release];
    [labelname release];
    [labelurl release];
    [labelimg release];
    [agent_name release];
    [agent_url release];
    [agent_img release];
    [promo_date release];
    [super dealloc];
}

@end

@interface PromoSkinValueObject : NSObject {

    NSString *promo_skin_url;  // the string I'm after
    NSString *promo_skin_id;

}

@property(nonatomic,retain)NSString *promo_skin_url;
@property(nonatomic,retain)NSString *promo_skin_id;


@end



   #import "PromoSkinValueObject.h"


    @implementation PromoSkinValueObject
    @synthesize promo_skin_url;
    @synthesize promo_skin_id;
    @end

//trying to add dot syntax here

This line of code is in a class which sytesizes promoValueObject

NSString *skin=promoValueObject.promoSkin.promo_skin_url;
  • 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-13T18:47:05+00:00Added an answer on May 13, 2026 at 6:47 pm

    The dot syntax is designed to be an exactly precise synonym for method invocations to methods that play the setter/getter role. To use the . [dot] syntax, the type of the object must be exactly specified and the object must implement the appropriate method. Dot syntax is not used to somehow gain direct access to instance variables.

    Thus, you say:

    And ClassB has a variable named
    myString of type NSString;

    And this is likely the problem. You need to either define methods to access myString or declare a property and @synthesize the methods. Either will work and both are effectively equivalent (save for the details of method synthesis when using atomic).


    It appears you are confusing “class” and “instance”. Everything in your code points to instances of this and that and you are trying to do something like this.that.something where something is failing?

    The problem is that you are using @class to forward declare the class reference. Basically, until the full class definition is seen by the compiler, any expression like Foo * where the compiler has only seen @class Foo; acts like a generic reference to an instance of a class of unspecified type (kind of like, but not quite, id).

    You need to #import the files containing the declarations of your classes. Think of it in terms of compiler visibility. When you compile the file that has the dot syntax expression, consider the exact set of declarations the compiler has seen prior to that expression being compiled. If the @interface for the class hasn’t been seen, you can’t use dot syntax on an instance of that class.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.