Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Need help accessing public Ivar

Hi,

I'm a newbie when it comes to iOS Programming. But after weeks of digging through API's, docs and much trial and error I can now proudly say that the idea I had in mind is up and running in my first iOS App. There are some things i am struggling with though.

For the sake of neat code and OOP (Object Oriented Programming) I wanted to separate some of my code in some separate class files. In this way I can separate my game logic from other code, say Twitter connection. This shouldn't be much of a problem, but I have some problems transferring data from the one to the other file. I'll try to illustrate what I'm doing (shortened):


// ViewAController.h
#import ViewBController.h

// ViewAController.m
-(void)viewDidLoad {
[ViewBController getIntX];
}

// ViewBController.h
int X;
+(int) getIntX;

// ViewBController.m
-(void)viewDidLoad {
X = 20;
}
-(int) getIntX {
return &(X);
}


Of course this is not my complete code, but it should give you an idea of what happens with this variable. Any help on how to acces a simple int X (directly or through getIntX) in ViewBController from ViewAController? Thanks a lot in advance!
Post edited by Dimiter on

Replies

Sign In or Register to comment.