这个问题与使用 Mobile Substrate 挂钩,但只要您了解 Objective-C,您可能会有所帮助。
我有这个类是我从 UIKit 中丢弃的。这是其中的一部分:
@interface UIStatusBarItem : NSObject {
int _type;
}
@property(nonatomic, readonly, retain) int type;
@property(nonatomic, readonly, retain) int leftOrder;
@property(nonatomic, readonly, retain) int rightOrder;
@property(nonatomic, readonly, retain) int priority;
...
@end
当然,如果我想设置int type
为例如 16,我会这样做:
MSHookIvar<int>(self, "_type") = 16;
从此,[self type]
将返回16。我知道的就这么多了。
我的问题是我不知道编译器“命名”了,和int
的值的存储位置。我试过:int leftOrder
int rightOrder
int priority
MSHookIvar<int>(self, "leftOrder")
但这是不正确的,会使手机崩溃。我真正需要知道的是,如果您自己不指定这些变量是如何自动命名的。谢谢
另外,我讨厌听起来像个刺头,但请不要仅仅回答“不要这样做,这不安全”。我知道不是,这就是为什么我的大部分产品都在 Cydia 而不是 App Store =P