user3195648
user3195648

Reputation: 67

iphone-Changing float in second ViewController

I have two ViewController , ViewController and getraenkeController.

Now in ViewController.h is float named getraenk. I read that I should do it like this:

@property float getraenk;

and then in getraenkeController.m I should do this:

ViewController.getraenk

but that doesn't work.

I also importet the header from ViewController.h

Now how can I access the float from ViewController in getraenkeController?

Upvotes: 0

Views: 48

Answers (2)

Robert
Robert

Reputation: 3880

First declare public property if you use ARC :

@property(nonatomic, assign) float getraenk;

and then you must create object of ViewController class e.g.:

ViewController *obj = [ViewController new];

now you should get access to getraenk property e.g.:

obj.getraenk

Upvotes: 0

Mick MacCallum
Mick MacCallum

Reputation: 130212

The float is added as a property to instances of the class, not the class itself. Once you create an instance of the class, then you'll be able to access the property.

ViewController *controller = [[ViewController alloc] init...];
controller.getraenk = 4334.3;

Upvotes: 1

Related Questions