开发者

Reset property in application delegate class

I have following code in app delegate class

开发者_如何转开发@interface AppDelegate : NSObject <UIApplicationDelegate> {
    NSString *url;
}

@property (nonatomic, retain) NSString *url;

@end

I initialised the url property in implement code.

Then in a view controller, I get the app delegate instance by:

appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

But if I reset the url using [appDelegate setUrl: nil], it won't empty that property completely, I go another controller, it's still not empty.


The example you show should work just fine. However, I suggest you to write a custom setter for the string in the app delegate. This way you will be able to see if your method get called. You could also try sending a notification in order to change this app delegate property, and this will allow you to do that from anywhere in your app.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜