开发者

Using a BOOL Variable in a app Delegate : makes pointer from integer without a cast

I`m doing something wrong with my app delegate,开发者_运维百科 I'd appreciate if someone could have a look at this one .

My AppDelegate.h :

{

BOOL *moveState;

}

@property (nonatomic) IBOutlet BOOL *moveState ;

My AppDelegate.m:

@synthesize moveState;

and my ViewController from where I'm trying to set the moveState value :

AppDelegate *moveUp = (AppDelegate *) [[UIApplication sharedApplication] delegate];

[moveUp setMoveState:YES];

It`s returning : makes pointer from integer without a cast


You declare a pointer to BOOL (BOOL *moveState) instead of a plain BOOL (BOOL moveState). Just change your interface:

@interface Application : NSObject <UIApplicationDelegate> {
    BOOL moveState;
}
@property(nonatomic, assign) BOOL moveState;
@end

And by the way, you are probably designing the code wrong by storing the move state flag in the application delegate. Does the move state have anything to do with the application lifecycle? If not, why are you storing it in the application delegate? So that you can get it everywhere in the application through [[UIApplication sharedApplication] delegate]? That’s misusing the singleton pattern, take a good look at Miško Hevery’s article called Singletons are Pathological Liars and the articles linked from there.


You used BOOL * when you probably meant to use BOOL.


Dont need to user pointer for BOOL only BOOL moveState will do ..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜