Reputation: 239
i am making game in which i am not using navigation controller but hiding and unhiding different controllers now my problem is as below
This Is going to be view long description you can understand what i am talking about
my flowConverViewController is like this
#import <UIKit/UIKit.h>
#import "FlowCoverView.h"
#import "NewGameController.h"
#import "MenuController.h"
@class NewGameController;
@interface FlowCoverViewController : UIViewController <FlowCoverViewDelegate>
{
}
@property (nonatomic, strong) NewGameController *game;
- (IBAction)done:(id)sender;
@end
flowcontroller.m is like below
when user click on image then image get selected and game should get start for that delegate method get called which is below
- (void)flowCover:(FlowCoverView *)view didSelect:(int)image
{
NSLog(@"Selected Index %d",image);
UIImage *newimage = [self flowCover:view cover:image];
[
NSLog(@"%@",[self.game menu]); // this shows null
NSLog(@"%@",self.game); // this shows null thats why my below methods which are in another class is not getting called
[self.game menu] playMenuSound];
// game is object of newGameController that we created in .h file and in
same way in newgamecontroller there is object properly of menu class and
playMenuSound is method in menu class
[self.game imagePickedFromPuzzleLibrary:newimage];
[self.game startNewGame];
}
only problem is this methods are not getting called as it shows null i know that i can alloc init them but i cant do that previous data will get lost i have alloc init this properties in previous classes .
newgamecontroller.h
@property (nonatomic, assign) MenuController *menu;
newgamecontroller.m
{
FlowCoverViewController *c = [[FlowCoverViewController alloc] init];
c.game = self;
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestFC" owner:self options:nil];
c = [array objectAtIndex:0];
[self presentModalViewController:c animated:YES];
}
Upvotes: 0
Views: 63
Reputation: 5616
I'm sorry, you do:
FlowCoverViewController *c = [[FlowCoverViewController alloc] init];
c.game = self;
and then you assign to c
a different object with:
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestFC" owner:self options:nil];
c = [array objectAtIndex:0];
[self presentModalViewController:c animated:YES];
How could c
still have the property c.game
set properly??
EDIT: Try instead
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestFC" owner:self options:nil];
FlowCoverViewController *c = [array objectAtIndex:0];
[self presentViewController:c animated:YES completion:nil]
and let me know.
Upvotes: 1