small medium large xlarge

Me_pragsmall
02 Jun 2010, 04:46
Jeff Cohen (19 posts)

Hi,

When I used to do C# development, the IDE had support for creating “control arrays”. Does Objective-C/IB support this in any way?

Here’s an example. For my first Objective-C app, I thought I’d try to write a game of Othello. Inspired by the chapters on KVC, my thought was to create 64 NSButton controls, one for each square on the board; and have each square observe a particular “Square” object owned by a “Game” object.

But setting up the UI seems tedious. Without direct support for control arrays, I think I have to:

Create 64 individual NSButtons in IB

# Create 64 outlets in my GameController # Wire up all 64 buttons to the outlets by hand in IB # Create an NSMutableArray to hold the 64 buttons in GameController.init() and have them observe the appropriate squares

This sounds… wrong. What’s the “Objective-C Way” of doing this kind of thing?

Thanks! The book has been awesome for getting my started with Mac programming.

You must be logged in to comment