开发者

Can Objects Call the Main Application?

Please bear with me, this is probably a very simple problem for an expert but I'm new to the language.

I'm trying to create an application that dynamically generates and releases a series of views, which are displayed in the main window. The problem I am having is in swapping between them. I want each view to contain buttons that cause the view to change. I can make a view close itself, but I don't know how to order the main program to change its own view to something new once that's been done (i.e. message the main application from within one of its child objects). I suppose I could make the main view of the application into a global, but I'd rather be able to contact the main application directly as this strikes me as being somewhat neater and less prone to other problems. Problem is, I don't know the main app's identifier. The convenient 'self' identifier gets used so often that I've never seen a code snippet that contains an identifier for the main application that could be called from outside it. It would also be useful to be able to link NIB file objects directly to attributes held in common by the main program.

Am I going about this in entirely the wrong way? Is there a generic 'main app' identifier? Is it possible to create on开发者_StackOverflow社区e, if one isn't generated automatically?

-Ash


Assuming that by 'main application' you mean your app delegate, you can get it using this method :

MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜