• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem instantiating an array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem instantiating an array


  • Subject: Problem instantiating an array
  • From: Dennis Birch <email@hidden>
  • Date: Sun, 5 Dec 2010 10:39:02 -0800

I'm new to Cocoa programming and brand new to this list, so I hope it's appropriate to ask this question here.

I've run into a showstopper with my first project on my own (i.e. not a project from a book). I've created a custom View subclass, and when I try to instantiate an array of another custom subclass, it completely fails to do so, but doesn't produce any meaningful errors. I can see that it's failing in the debugger because after stepping after the line "TileColumn *allColumns[boardDimension - 1]", the array remains with a member count of -1. In the for loop, the line "allColumns[i] = column;" doesn't produce any errors but doesn't change the array. I'm stumped as to what I've done wrong here. I DO have an instance of MMGameView in the main window.

Here's the first part of my class's m file:

#import "MMGameView.h"
#import "TileColumn.h"
#import "GameTile.h"


int boardDimension = 16;

@implementation MMGameView

-(BOOL) acceptsFirstResponder{
	return YES;
}

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code here.
		TileColumn *allColumns[boardDimension - 1];
		for (int i = 0; i < boardDimension; i++)
		{
			TileColumn *column = [[TileColumn alloc] init];
			allColumns[i] = column;
		}

		gameColumns = [NSArray arrayWithObjects:allColumns count: boardDimension];
	}
    return self;
}_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem instantiating an array
      • From: Conrad Shultz <email@hidden>
    • Re: Problem instantiating an array
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Source files are not shown in the Xcode
  • Next by Date: problem with core data and uno
  • Previous by thread: Re: Source files are not shown in the Xcode
  • Next by thread: Re: Problem instantiating an array
  • Index(es):
    • Date
    • Thread