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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:33:41+00:00 2026-05-20T04:33:41+00:00

#import<Foundation/Foundation.h><br/> #import QuestionItem.h int main (int argc, const char * argv[]) { NSAutoreleasePool *

  • 0
#import<Foundation/Foundation.h><br/>
#import "QuestionItem.h"

int main (int argc, const char * argv[]) {

NSAutoreleasePool * pool        = [[NSAutoreleasePool alloc] init];
// NSMutableArray    *itemQuestion = [[NSMutableArray alloc] init];

// QuestionItem *newQuestion = [[QuestionItem alloc] init];
[QuestionItem aQuestion:@"Question to be answered" Ans: [NSMutableArray arrayWithObjects: @"Answer", @"Distractor1", @"Distractor2", nil]];

// [newQuestion initWithQuestion:@"Twas Brillig"];
// [newQuestion QuestionInstance:@"Test"];

// [newQuestion initWithAnswerMatrix: [NSMutableArray arrayWithObjects: @"First", @"Second", nil]];
// [newQuestion AnswerMatrixInstance: [NSMutableArray arrayWithObjects: @"First", @"Second", nil]];

// [newQuestion initWithQuestionAndAnswer:@"Jumping Jacks" Answer:[NSMutableArray arrayWithObjects: @"First", @"Second", nil]];

// NSLog(@"Hello, World!");

[pool drain];
return 0;
}

//
//  QuestionItem.h
//  NewQuestions

// I shouldn't be moving around mutables?
// Use NSCopy(ing) instead?

#import <Foundation/Foundation.h>

@interface QuestionItem : NSObject {

NSString       *question;
NSMutableArray *answerMatrix;
NSDate         *dateCreated;
}

@property (nonatomic, copy) NSString           *question;
@property (nonatomic, copy) NSMutableArray     *answerMatrix;

+ (id) aQuestion: (NSString *) qClassParam Ans: (NSMutableArray *) aClassParam;

- (id) init;
// - (id) initWithQuestion:(int)question;
- (id) initWithAnswerMatrix:(NSMutableArray *) answerMatrix;
- (id) initWithQuestionAndAnswer:(NSString *)  question Answer:(NSMutableArray *)answerMatrix;

- (id) QuestionInstance:    (NSString *)       qInstanceParam;
- (id) AnswerMatrixInstance:(NSMutableArray *) amInstanceParam;

@end

//
//  QuestionItem.m
//  NewQuestions
//

#import "QuestionItem.h"

@implementation QuestionItem

@synthesize question, answerMatrix;

+ (id) aQuestion: (NSString *) qClassParam Ans: (NSMutableArray *) aClassParam {

QuestionItem *newQuestionItem = [[self alloc] initWithQuestionAndAnswer:qClassParam Answer: aClassParam];

return newQuestionItem;
}

- (id) init {

    if((self = [super init])) {

        /* initializations go here */
    }

return self;
}

- (id) initWithQuestion: questionParam {

    [self init];
    [self QuestionInstance: questionParam];

    return self;
}

- (id) initWithAnswerMatrix: (NSMutableArray *) answerMatrixParam {

    [self init];
    [self AnswerMatrixInstance:answerMatrixParam];

    return self;
}

- (id) initWithQuestionAndAnswer: (NSString *) questionParam Answer: (NSMutableArray *) answerMatrixParam {

    [self init];
    [self QuestionInstance: questionParam];
    [self AnswerMatrixInstance:answerMatrixParam];

    return self;
}

- (id) QuestionInstance: (NSString *) qInstanceParam {

    NSLog(@"QuestionInstance: %@", qInstanceParam);

    return qInstanceParam;
}

- (id) AnswerMatrixInstance: (NSMutableArray *) amInstanceParam {

    for (int i=0; i < [amInstanceParam count]; i++) {

        NSLog(@"AnswerMatrixInstance: %@", [amInstanceParam objectAtIndex:i]);
    }

    return amInstanceParam;
}

@end
  • 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-20T04:33:41+00:00Added an answer on May 20, 2026 at 4:33 am

    Override NSObject’s description method. Add something like this to QuestionItem.m

    - (NSString *)description 
    {
        return [NSString stringWithFormat:@"%@", question];
    }
    

    You can build whatever string you want to return in the description method.

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

Sidebar

Related Questions

#import <Foundation/Foundation.h> int main (int argc, char const *argv[]) { SampClass *obj=[[SampClass alloc] init];
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { @autoreleasepool { NSMutableArray
Here is my code #import <Foundation/Foundation.h> int main (int argc, const char * argv[])
Here is retaincount code. #import <Foundation/Foundation.h> int main (int argc, const char * argv[])
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { NSArray *array
#import <Foundation/Foundation.h> typedef struct Node { int offset; } Node; int main (int argc,
Here's my code: #import <Foundation/Foundation.h> void PrintPathInfo() { const char *path = [@~ fileSystemRepresentation];
I have a very simple Objective-C sample #import <Foundation/Foundation.h> int littleFunction(); int main (int
Below is my code: First Category.h #import <Foundation/Foundation.h> @interface Category : NSObject { NSMutableArray

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.