开发者

Release static int variable

开发者 https://www.devze.com 2022-12-16 00:02 出处:网络
How to \"clean\" static int variables in a view class method? Every time a get back to this view I need those vars \"zeroed\". The [self.view removeFromSu开发者_运维百科perview];

How to "clean" static int variables in a view class method? Every time a get back to this view I need those vars "zeroed". The [self.view removeFromSu开发者_运维百科perview]; instruction does not seem enough to free up memory from those vars.

Thank you. Have a great 2010!

These int vars are declared static in a view method. They are not global in the view class.


If you don't want a static value to stick around, don't make it static.


You'll have to manually do this by defining a setValue method similar to:

@interface MyClass 
{
  // ...
}
+ (NSString *)myVar;
+ (void)setMyVar:(NSString *)newVa;
@end

@implementation MyClass
static NSString *myVar;
+ (NSString *)myVar { return myVar; }
+ (void)setMyVar:(NSString *)newVar { myVar = newVar; }
@end
0

精彩评论

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