开发者

Handling memory warning on views that wont behave the same if if i reload

开发者 https://www.devze.com 2023-03-04 01:11 出处:网络
Part of my program parses and RSS feed depending on which feed was chosen from a tableview. to pass the url of the rss file, i am creating a new view controller, and calling a function

Part of my program parses and RSS feed depending on which feed was chosen from a tableview.

to pass the url of the rss file, i am creating a new view controller, and calling a function

setURL:(NSString*)url withTitle:(NSString*)title ..... 

on it... (then I push it) in viewDidLoad of that viewController, i start the parsing for that URL and so on.

Now if i get a memory warning when this view isnt visible. (eg, i choose an article to go on and view it's summary), how can i release this view in a way that i can get back the relevant table when i come back? I hope i'm being clear. my question is that if the viewcontroller is freed, then i lose the URL that it is supposed to parse. When re-allocing it, the viewDidLoad will try to parse an invalid url, and i shudder to think what will happen. :|

What can i do to solve this problem? do i ignore the memory warning on this viewController, and just focus on freeing the other ones?开发者_Python百科

Thanks, and i hope I make myself clear.


your question is not very clear. but your viewcontroller shouldn't be freed or dealloceted on a mem warning, only it's view property is being freed by ios. So IMHO, you are storing the url in a wrong place..try storing it in an ivar on the view controller, and setting it on the init method. That way it should be available across the whole viewcontroller's life cycle even if a mem warning is encountered.

0

精彩评论

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

关注公众号