• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Calling maincontroller
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling maincontroller


  • Subject: Calling maincontroller
  • From: Hans van der Meer <email@hidden>
  • Date: Thu, 7 Oct 2010 20:58:40 +0200

In my application I instantiate a MainController (the delegate having "awakeFromNib) from where all actions are dispatched. In order to send messages to the displaywindow residing in MainController, there is the problem how to find this MainController from other callers (possibly on other threads). Now it is coded as follows:

In MainController.c:
  static MainController *controller = nil;
  controller = self; /* in its init method */
  + (void) message:(NSString *)msg;
    { dispatch_async(dispatch_get_main_queue(), ^{[controller message:msg];});}
  - (void) message:(NSString *)msg;

I am not very happy with the static variable but do not see another way to accomplish this. I fear my solution is not as much in the spirit of Cocoa programming as it should be.
Is there a better way?

Hans van der Meer

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Calling maincontroller
      • From: Quincey Morris <email@hidden>
    • Re: Calling maincontroller
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: Problem connecting to Oracle with app run from XCode
  • Next by Date: Re: Calling maincontroller
  • Previous by thread: Re: reused tableViewCell UILabel text is deallocated but not nil ??
  • Next by thread: Re: Calling maincontroller
  • Index(es):
    • Date
    • Thread