开发者

Release static int variable

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜