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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:33:36+00:00 2026-05-23T18:33:36+00:00

I don’t have a clue why this error is showing. I have the following

  • 0

I don’t have a clue why this error is showing. I have the following class:

#import <Foundation/Foundation.h>
#import "Answer.h"

@interface Question : NSObject {
    NSString* qId;
    NSString* qTitle;
    NSString* qNumber;  
    NSString* sectionId;
    NSString* qType;
    Answer* answer;
}

@property (nonatomic, retain) NSString* qId;
@property (nonatomic, retain) NSString* qTitle;
@property (nonatomic, retain) NSString* qNumber;
@property (nonatomic, retain) NSString* sectionId;
@property (nonatomic, retain) NSString* qType;
@property (nonatomic, retain) Answer* answer;

#import "Question.h"

@implementation Question
@synthesize qId, qTitle, qNumber, sectionId, qType, answer;

-(id)init
{
    if (self = [super init])
    {
        // Initialization code here
        answer = [[Answer alloc]init];
    }
    return self;
}

-(void) dealloc{
    [answer release];
    [super dealloc];
}

@end

I have a property of type Question in the following class:

#import <Foundation/Foundation.h>
#import "TextInputQuestion.h"

@interface TextInputQuestionViewController : UIViewController {
    Question *question;
    IBOutlet UILabel *questionTitle;
    IBOutlet UILabel *inputLabel;
    IBOutlet UITextField *inputAnswer;
}

@property (nonatomic, retain) UILabel *questionTitle;
@property (nonatomic, retain) UILabel *inputLabel;
@property (nonatomic, retain) Question *question;
@property (nonatomic, retain) UITextField *inputAnswer;

- (void) addButton:(id)sender isLast:(BOOL)last;
- (void) setQuestionId:(NSString*)quId withTitle:(NSString*)quTitle number:(NSString*)quNum section:(NSString*)sId questionType:(NSString*)qt;

@end

I synthesize Question* question in the .m file.

In my QuestionnaireVieController class:

#import <UIKit/UIKit.h>
#import "JSONKit.h";
#import "dbConnector.h"
#import "SliderQuestionViewController.h";
#import "TextInputQuestionViewController.h";
#import "MainMenuProtocol.h";

@interface QuestionnaireViewController : UIViewController {
    NSDictionary* questions;
    NSMutableArray* questionArray;
    NSMutableArray* answerArray;
    dbConnector* db;
    NSInteger currQNum; 
    NSString* qaTitle;
    NSString* secId;
    id<MainMenuProtocol>delegate;
}

@property(nonatomic, retain) NSDictionary* questions;   
@property(nonatomic, retain) NSMutableArray* questionArray;
@property(nonatomic, retain) NSMutableArray* answerArray;
@property(nonatomic, retain) dbConnector* db;
@property(nonatomic) NSInteger currQNum;
@property(nonatomic, retain) NSString* qaTitle;
@property(nonatomic, retain) NSString* secId;
@property(nonatomic, retain) id <MainMenuProtocol> delegate;

-(void) setQuestions;
-(void) startQuestion:(NSInteger)index isLast:(BOOL)last;
-(void) loadQuestions;
-(void) initialise;
-(void) finishQuestionnaire:(id)sender;
-(void) switchViews:(id)sender;

@end

I use the following method in the .m file to populate the questionArray with different types of viewcontroller:

//assigns JSON to question objects
-(void) setQuestions {
    questionArray = [[NSMutableArray alloc] init];
    for (NSDictionary *q in self.questions) {               
        /* Create Question object and populate it */

        id question;
        if([[q objectForKey:@"type"] isEqualToString:@"Slider"]){
            question = [[SliderQuestionViewController alloc]init];              
            //set min max values
        }else if([[q objectForKey:@"type"] isEqualToString:@"Option"]){

        }else if([[q objectForKey:@"type"] isEqualToString:@"TextInput"]){
            question = [[TextInputQuestionViewController alloc]init];                       
        }else if([[q objectForKey:@"type"] isEqualToString:@"ImagePicker"]){

        }else{
            //comments          
        }
        [questionArray addObject:question];
        [question setQuestionId:[q objectForKey:@"questionId"] withTitle:[q objectForKey:@"question"] number:[q objectForKey:@"questionNumber"] section:[q objectForKey:@"sectionId"] questionType: [q objectForKey:@"type"]];
        [question release];

    }
}

When I do the following in the above .m file:

NSLog(@"%@", [questionArray objectAtIndex:0]);

I get:

<TextInputQuestionViewController: 0x6062e90>

When I try to do:

NSLog(@"%@", [questionArray objectAtIndex:0].question);

I get an error:

request for member 'question' in something not a structure or union

Why on earth can it not access the question variable? Especially when it actually logs my controller object. am I missing something here…

  • 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-23T18:33:37+00:00Added an answer on May 23, 2026 at 6:33 pm

    You’re running into the madness that is dot-notation. Switch it to this, and I bet it works (or at least you get a useful error):

    NSLog(@"%@", [[questionArray objectAtIndex:0] question]);
    

    Dot-notation is a slapped-on addition in ObjC2, and the compiler still can’t always figure it out, especially when you’re trying to pass a message to an id (like objectAtIndex: returns). The compiler gets confused, thinks this this is the dot you use for a struct rather than a message in disguise, and bails.


    EDIT

    foo.bar = baz;
    => [foo setBar:baz];
    
    foo.bar.baz
    => [[foo bar] baz];
    

    This, btw, is actual Objective-C. Dot-notation is just a sloppy way of writing this. In particular, it’s important to understand that foo.bar=baz is exactly “send the message setBar: to foo.” The default behavior for that is to assign a property using the declared setter semantics, but that’s just the default. You can override setBar: to do anything. You can even reconfigure the message dispatch system to not call the method setBar: (this is not an obscure feature, it’s used by Core Data and Core Animation). Objective-C is a dynamic language, and unfortunately dot-notation tends to muddy this by making it look like Java.

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

Sidebar

Related Questions

don't know better title for this, but here's my code. I have class user
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't know if this has been asked before, so point me to another question
I don't know if this question is trivial or not. But after a couple
Don't overthink this - there's a very commonly used term and I ... have
Don't think my virtualhost is working correctly. This is what I have inside of
Don't know what to do with this error. How to add data in SQL
Don't know if this has been answered before. Have custom routes to users. If
Don't know why but I can't find a solution to this. I have 3
Don't know why this conversion fails. SELECT CAST('32.999' AS INT) throws the error saying

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.