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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:23:01+00:00 2026-05-21T23:23:01+00:00

I am very new to objective-c and im trying to declare a new instance

  • 0

I am very new to objective-c and im trying to declare a new instance of UITableView in XCode. Here is my code:

UITableView *mainTable = [[UITableView alloc] init];

and XCode is pointing at the = and bothering me about a semicolon at the end of the declaration statement, which is obviously there.

EDIT:

#import <UIKit/UIKit.h>

@interface TestRunAppDelegate : NSObject <UIApplicationDelegate> {

    UITableView *mainTable = [[UITableView alloc] init];

}
  • 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-21T23:23:02+00:00Added an answer on May 21, 2026 at 11:23 pm

    You can’t make assignments inside your class’s interface.

    Move the assigment to your app delegate’s init method:

    #import <UIKit/UIKit.h>
    
    @interface TestRunAppDelegate : NSObject <UIApplicationDelegate> {
    
        UITableView *mainTable;
    
    }
    @end
    
    @implementation TestRunAppDelegate
    
    - (id)init {
    
        if( !(self = [super init]) ){
            return nil;
    
        mainTable = [[UITableView alloc] init];
    
        return self;
    }
    @end
    

    The @interface block (everything from @interface to @end) simply tells other code what to expect from your class. It doesn’t do anything itself. Between the curly braces, you declare instance variables, but don’t actually create any objects. After the instance variable declaration and before @end, you declare your methods. Again, you don’t implement them. You’re simply letting the compiler, and any other code that imports your header, know what they can expect your class to do.

    The reason for separating the implementation and interface in this way* is to realize one of the tenets of object-oriented programming. An object essentially tells other objects what it can do (the interface), but makes no statement as to how it will accomplish a task (implementation).


    *They are usually put into two separate files but don’t actually have to be.

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

Sidebar

Related Questions

I'm very new to Objective-C and I'm trying to develop an iPhone app. My
I am very new to xcode & Objective-C (having come from PHP) i have
Im very new to Objective-C and am currently learning how to use Xcode and
I'm VERY new to WPF, and still trying to wrap my head around binding
Okay, just for starters, I am very new to Objective-C, (C in general). I
I am very new to Objective-C and was reading through memory management. I was
I have some Objective-C++ code that I'm trying to get events out of an
I am fairly new to Objective C and iOS programming but am constantly trying
Very new to Iphone development here, I have a project which is successfully building
I am very new to stored procedures. I am trying to make a stored

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.