开发者

Reset property in application delegate class

开发者 https://www.devze.com 2023-03-19 17:18 出处:网络
I have following code in app delegate class 开发者_如何转开发@interface AppDelegate : NSObject <UIApplicationDelegate> {

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

精彩评论

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