//AppDelegate.h
AppDelegate NSInteger myInt;
@property (readwrite, assign) NSInteger myInt;
//AppDelegate.m
@synthesize myInt;
//MyClass.h
AppDelegate *objAppDelegate;
//MyClass.m
objAppDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
当我尝试为 myInt 赋值时
objAppDelegate.myInt=(NSInteger *)0; // <--- this gives warning: something like incompatible pointer to integer conversion like that
那么,我该如何分配这个变量呢?
最佳答案
objAppDelegate.myInt = (NSInteger)0;
或
objAppDelegate.myInt = 0;
您应该在没有指针的情况下分配给 NSInteger。
关于iphone - 如何在派生类中分配全局 NSInteger 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11327432/