Klurby Mac OS

I’ve been working on a Mac app lately, and while some things are similar to iOS, something are definitely different. One thing that is different are modal windows and run loops.

  1. Kirby Mac Os Download
  2. Klurby Mac Os Download
  3. Kirby Mac Os Catalina

When you display a modal view on iOS you don’t get a new run loop for the view, but when you display a modal window on OS X a new run loop is created for the window. This is not necessarily a big deal unless you have a habit of using GCD to dispatch work between background and main queues. Let me give a more specific example.

I display a modal view, or in the cause of OS X, a modal window. The current view is managed by a view controller. User input is captured, then a URL request is sent off to a server on the Internet. The view controller is then notified when the URL request completes.

The typical pattern I follow for sending the request to the server and getting notified when done is to call a method that will dispatch the URL request to a background queue then dispatch to the main queue to call a block when complete. It looks something like this:

This is a simplified view of the pattern I often use. Call a method with a callback block. Perform some work on a background thread. When done, call the callback block on the main thread.

38 Games Like Kirby: Triple Deluxe for Mac. A quiet life in Dream Land is never a guarantee for Kirby, especially when his house gets hoisted up to the land of Floralia, one night. Being stuck at the top of the Dreamstalk is bad enough but now King Dedede’s been royally kidnapped, too – it’s downright inconvenient! Xbox 360, PlayStation 3, Microsoft Windows, Mac OS X; the titular campaign is a sequel to the original game, but an enhanced remake of the original is included Sid Meier's Colonization: 1994 DOS: Civilization IV: Colonization: 2008 Microsoft Windows, Mac OS X Comic Party: 1999 Microsoft Windows, Dreamcast: Comic Party Portable: 2005. Barney takes over my MacBook Air! And calls the O.S. Mac OS X Barney. We will see what happens in this video. And the begining is a bit short. There is caillou playing the computer. I like kirby for real but when I made this video, I hate kirby but just for fun.Note: Please don't take this way too s. Welcome to Kirby's world! It's rude, crude, and totally sketchy. Thirteen-year-old Kirby Buckets dreams of becoming a famous animator. Whether running away from clowns or driving his sister 'Dawnzilla' nuts, it's never a dull day for Kirby and his bro's.

This pattern has served me well on iOS, but it has issues on Mac OS X when displaying a modal window.

When you display a modal window with +[NSApp runModalForWindow:] a new run loop is created for the window1. That might seem fine until you call dispatch_async(dispatch_get_main_queue(), ^{}) from a background thread. The block that you are trying to execute in the main queue will never run. And in my case, the completion block is never called. This means my modal window never receives the notification that the URL request completed. (NOTE: Mike Ash pointed out that it’s not the new run loop that causes the problem.)

So how did I work around this problem?

Instead of dispatching the completion() to the main queue, I call it directly from the background thread. In the completion block itself, I decide how to get the code should run in the main thread. If my window isn’t modal, then I can use dispatch_async(dispatch_get_main_queue(), ^{}). But if my window is modal, which just happens to be the case for the app I’m working on, then I use -performSelectorOnMainThread:withObject:waitUntilDone:. So the code in my view controller looks something like this:

This pattern change now has me re-thinking how I use certain patterns in my code, especially for code that I intend on sharing between the two platforms.

Update: I posted a sample project that illustrates the problem. In writing the sample app, I learned that the scenario that causes the problem is when the modal window is presented via a block that is dispatched asynchronously on the main queue.

Update 2: Mike Ash pointed out that NSRunLoop is reentrant but GCD serial queues are not and this is the reason, not my theory of a different event loop, the block isn’t executed. Mike said, “The main queue is already executing a block, and it won’t execute a new one until that one is done. This is a subtle way in which dispatch on the main queue isn’t the same as performSelectorOnMainThread.”

Good to know and thanks, Mike, for explaining what is happening.

  1. From the Apple documentation for +[NSApp runModalForWindow:]: “This method runs a modal event loop for the specified window synchronously. It displays the specified window, makes it key, starts the run loop, and processes events for that window. (You do not need to show the window yourself.) While the app is in that loop, it does not respond to any other events (including mouse, keyboard, or window-close events) unless they are associated with the window. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. In other words, this method consumes only enough CPU time to process events and dispatch them to the action methods associated with the modal window.” ↩

Posted in programming. Tagged in objective-c, os x.

Related Articles

Here is a definitive guide to setting up virtual hosts on OS X, the instructions work on all versions from Leopard to Lion/Mountain Lion.

If you have lots of sites to test, you might want to be able to type a url into the browser, and see the site directly. To do that you need to modify your Mac’s hosts file, and set up a Virtual Server.

Updated Feb 2012

Preparation

Decide upon the URL you want to use, I’m going for mark-kirby.dev in this example.

Decide where you want the files to go that will appear for this url, and place them there on your computer. I’m using /Users/username/Sites/mark-kirby for this example.

Start apache with terminal:

2 - Edit the hosts file

Open the file at ‘/private/etc/hosts’

Kirby Mac Os Download

Since this file is hidden, you will need to need to check the option “open hidden files” if your text editor has one, or use the terminal to open the file directly.

Alternatively, you could:

  1. Open finder
  2. click on go
  3. select “Go to folder”
  4. enter in /private/etc/

You will see the following:

Underneath this, enter your local IP address (127.0.0.1) and the name of the site you want to set up, e.g.

Save the file - you will have to authenticate - and now when ever you type http://mark-kirby.dev into a browser it will give you your local folders - EVEN if mark-kirby.dev is an actual website on the internet. Browsers always check the hosts file first.

Add the virtual host in apache

If you type mark-kirby.dev into your browser now, you will still see your default folders, you need do some more work.

Open the file /private/etc/apache2/extra/httpd-vhosts.conf

using the methods described above.

You will see this first:

First I’ll quickly explain what each line means:

  • ServerAdmin - the email address of the server admapachestrator e.g. mark-kirby@mark-kirby.dev, this will show up on error pages
  • DocumentRoot - the location of the files to show e.g. /User/username/Sites/mark-kirby
  • ServerName - the domain name you want to use e.g mark-kirby.dev
  • ServerAlias - an alternative name which will point to the same place e.g. www.mark-kirby.dev
  • ErrorLog - the location of a log file to output errors to, e.g. “/User/username/Sites/logs/mark-kirby-error-log”
  • CustomLog - the location of a file where all other logs should be written, followed by a format - just stick with common - e.g. “/User/username/Sites/logs/mark-kirby-access-log common”

So really, you only need DocumentRoot and ServerName if this is a test server only you will access.

Firstly comment out the examples - very important, don’t miss this step!

Then add a default entry so localhost will still take you to the root of your Sites folder:

Finally, add your entry, e.g.

Where {username} is your username.

Save this, you’ll need to authenticate.

Set Permissions on your sites folder

Thanks to Jeremy Keiths solution - we can ensure permissions are set to allow all sites to be viewed without setting them on each one. This is great for our purposes, but would never be used on a live server.

Add this to your vhosts file:

Activate virtual hosts in apache

If you haven’t done so, by default the file you just edited, won’t be enabled in Apache.

To change this open up another hidden file - /private/etc/apache2/httpd.conf

Find the line

And uncomment the include so it looks like this:

Mac os mojave

Save the file - you may need to authenticate.

Klurby Mac Os Download

Restart Apache

This still won’t work, until you restart apache.

Kirby Mac Os Catalina

To restart apache:

  1. Go to system preferences
  2. Select “sharing”
  3. Uncheck the box “Web Sharing” - apache will stop
  4. Check it again - apache will start

or:

Test your site - you should be in luck!

Please enable JavaScript to view the comments powered by Disqus.comments powered by Disqus