views:

77

answers:

1

I have a MainController, it creates an object(say polygon), a controller(say,polygonViewController). PolygonViewController has two outlets:

IBOutlet Polygon* aPolygon;
IBOutlet UILabel* numOfSidesLabel;

it mediates Polygon and PolygonViewController.xib file.

How do I make sure the PolygonViewController's aPolygon is the same(instance) as polygon created in mainController?

I tried to add @property Polygon* aPolygon; to PolygonViewController then in MainController I did polygonViewController.aPolygon = polygon; However, aPolygon in PolygonViewController awakeFromNib method is always null.

A: 

Have you tried to use a singleton object?

You can make your aPolygon class to be a singleton object so, you will be always working with the same object in as many viewControllers as you want to use it.

Take a look at: http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32

Hope this will help you!

Cheers,
VFN

vfn
hi vfn:this might be a possible solution. I would give it a go.cheers
Michael Z