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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:16:57+00:00 2026-05-11T22:16:57+00:00

I have the following objective C class. It is to store information on a

  • 0

I have the following objective C class. It is to store information on a film for a cinema style setting, Title venue ID etc. Whenever I try to create an object of this class:

Film film = [[Film alloc] init];

i get the following errors: variable-sizedobject may not be initialized, statically allocated instance of Objective-C class “Film”, statically allocated instance of Objective-C class “Film”.

I am pretty new to Objective C and probably am still stuck in a C# mindset, can anyone tell me what I’m doing wrong?

Thanks michael

code:

// Film.m
#import "Film.h"
static NSUInteger currentID = -1;

@implementation Film

@synthesize filmID, title, venueID;

-(id)init {

    self = [super init];

    if(self != nil) {
        if (currentID == -1)
        {
            currentID = 1;
        }
        filmID = currentID;
        currentID++;
        title = [[NSString alloc] init];
        venueID = 0;
    }

    return self;
}

-(void)dealloc {

    [title release];
    [super dealloc];
}

+(NSUInteger)getCurrentID {
    return currentID;
}

+(void)setCurrentID:(NSUInteger)value {
    if (currentID != value) {
        currentID = value;
    }
}

@end

// Film.h
#import <Foundation/Foundation.h>


@interface Film : NSObject {
    NSUInteger filmID;
    NSString *title;
    NSUInteger venueID;
}

+ (NSUInteger)getCurrentID;
+ (void)setCurrentID:(NSUInteger)value;

@property (nonatomic) NSUInteger filmID;
@property (nonatomic, copy) NSString *title;
@property (nonatomic) NSUInteger venueID;

//Initializers
-(id)init;

@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-11T22:16:57+00:00Added an answer on May 11, 2026 at 10:16 pm

    You need your variable that holds the reference to your object to be of a reference type. You do this by using an asterisk – see below:

    Film *film = [[Film alloc] init];
    

    Coming from Java I often think of the above as:

    Film* film = [[Film alloc] init];
    

    I tend to associate the ‘reference’ marker with the type. But hopefully someone more versed in C/C++/ObjC will tell me why this is wrong, and what the ‘asterisk’ is actually called in this context.

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

Sidebar

Related Questions

Say I have the following Objective-C class: @interface Foo { int someNumber; NSString *someString;
I have following classes. class A { public: void fun(); } class B: public
I have the following Objective-c Function - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger
I have gone through the following question. Objective C - Where do you dealloc
I have the following class hierachy: @interface Message : NSObject {} @end @implementation Message
I have the following ViewController class #import <UIKit/UIKit.h> @interface SampleViewController : UIViewController { IBOutlet
I have a following static method in one of my utility class + (UIImage
I have a question about the objective C. I have the following NSString *name
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;

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.