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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:48:38+00:00 2026-05-25T19:48:38+00:00

I am starting to program in Objective-C. I am using a book to learn

  • 0

I am starting to program in Objective-C. I am using a book to learn the first basics. The given example is not working! I can not see the problem in my code.
It was not so hard to understand it, but it just won’t work. But everything I found elsewhere, they added Objects like I did.
I don’t know if the syntax changed? I am using the iOS 4.3 SDK and Xcode 3.2.6!?
This part fails:

[questions addObject: @”What is 7 + 7?”]; //FAILS
[answers addObject: @”14”];

The error message says:
/Applications/Quiz/Classes/QuizAppDelegate.m:32:0
Applications/Quiz/Classes/QuizAppDelegate.m:32: error: expected expression before ‘@’ token

I would be really happy, if someone can help me!
Thank you!

I attached the code as well!

Jules

Full code: .h:

#import <UIKit/UIKit.h>

@interface QuizAppDelegate : NSObject <UIApplicationDelegate> {

    int currentQuestionIndex;

    //The model objects
    NSMutableArray *questions;
    NSMutableArray *answers;

    //The view objects
    IBOutlet UILabel *questionField;
    IBOutlet UILabel *answerField;

    UIWindow *window;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

-(IBAction)showQuestion:(id)sender;
-(IBAction)showAnswer:(id)sender;

@end

Part code where it fails: .m:

#import "QuizAppDelegate.h"

@implementation QuizAppDelegate

@synthesize window;

-(id)init{

    // Call the init method implemented by the superclass 
    [super init];

    // Create two arrays and make the pointers point to them 
    questions = [[NSMutableArray alloc] init]; 
    answers = [[NSMutableArray alloc] init];

    // Add questions and answers to the arrays 
    [questions addObject: @”What is 7 + 7?”]; //FAILS
    [answers addObject: @”14”];

    [questions addObject: @”Was ist die Hauptstadt von Madagaskar?”]; //FAILS
    [answers addObject: @”Antananarivo”];

    [questions addObject: @”Was ergibt 5-2*2+6?”]; //FAILS
    [answers addObject: @”7”];

    // Return the address of the new object 
    return self;

}

-(IBAction)showQuestion:(id)sender{

//Step to the next question
currentQuestionIndex++;

//Am I past the last question?
if(currentQuestionIndex==[questions count]){

    //Go back to the first question
    currentQuestionIndex=0;
}

// Get the string at that index in the questions array 
NSString *question = [questions objectAtIndex:currentQuestionIndex];

//Log the string to the console
NSLog(@"displaying question:%@",question);

//Display the string in the question field
[questionField setText:question];

//Clear the answer field
[answerField setText:@"???"];
}

-(IBAction)showAnswer:(id)sender{

//What is the answer to the current question
NSString *answer=[answers objectAtIndex:currentQuestionIndex];

//Display it in the answer field
[answerField setText:answer];
} 
  • 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-25T19:48:39+00:00Added an answer on May 25, 2026 at 7:48 pm

    I think, you are using the false character for the double quote “, as yours is ”. Did you copy and paste the code from somewhere?

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

Sidebar

Related Questions

I'm currently just starting my first Lua program and I have a .csv file
Having successfully gotten a sample program working, I'm now starting to do Real Work
I am starting to program for android, when I first try to run the
So the objective (well the starting point anyway) of this program is to press
I'm learning how to program, and starting off with Objective C. I'm trying to
Generally we import a tlb file at the starting of the program like #include
I'm starting work on a program which is perhaps most naturally described as a
I'm just starting out writing trying to write a simple program in C and
My program does some network activity in a background thread. Before starting, it pops
I'm just starting out in learning Ruby and I've written a program that generates

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.