iphone - 如何在派生类中分配全局 NSInteger 对象

标签 iphone objective-c ios delegates

//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/

相关文章:

iphone - NSString 不会在类之间传递

ios - 验证 iOS 的 url 以 www 开头

Objective-c 静态 NSArray 初始值设定项

objective-c - KVO 说 KVO 观察者已注册,即使它没有(或者是吗?)

ios - iOS 8 上 Swift 1.2 中的全局弹出框功能

ios - 您可以拥有多少个 UIApplicationShortcutItem 有限制吗?

iphone - 如何将 .ipa 文件安装到我的 iPhone 模拟器

iphone - 动画UIView时内存过度释放问题

ios - Firebase 身份验证尝试使用 Apple 的身份 token 会在 Xamarin.iOS 应用程序中返回 17999 INVALID_CREDENTIAL_OR_PROVIDER_ID

ios - 编译 Swift 时收到 “Include of non-modular header inside framework module”