Blogs

Simon 4.1b3 released

One more beta with a few fixes, for good measure. This will probably be the last beta before general release; please let me know if you find any issues.

  • If the When pop-up menu for a test filter is changed to None, the filter plugin controls are now removed, as expected.
  • Changed the (-) button to set the When pop-up menu to None for the last filter or notifier in the test.
  • Fixed an issue where the Preview source wouldn't finish loading if the Preview is displayed on launch of the app.

Download Simon 4.1b3 now!

Simon 4.1b2 released

Just been a couple of days, but here's another beta of Simon 4.1, with some exciting changes:

Redesigned Web feature

  • The Web (HTTP) editor has been significantly redesigned, to use a list of pages including Parameters, Headers, Cookies and Other. Clicking on one shows the corresponding page.
  • The Method pop-up menu is now on the Parameters page, since it indicates how the parameters are sent.
  • The Username and Password fields are now on the Other page; they are only useful if you connect to a server that has an authentication challenge (as displayed in a web browser via a sheet; not the same as a in-page form-based login).

Web feature support for custom headers

  • The new Headers list enables you to add custom headers to send with the request, e.g. Accept, User-Agent, etc.
  • Note that sending a request via Post will set the Content-Type and Content-Length headers, overriding any you may add.

Download Simon 4.1b2 now!

Simon 4.1b1 released

Time for an update to Simon! This first beta release includes:

Support for dynamic web content

  • Added an option to the Web (HTTP) service to enable capturing the rendered source some interval after the base HTML is loaded, to support including dynamic changes from JavaScript, as is more and more common nowadays.
  • Now does Post requests via the more compact application/x-www-form-urlencoded content type, instead of multipart/form-data. (Please let me know ASAP if this breaks any of your POST tests.)
  • Updated the web helper to 64-bit.

Other changes

  • When adding a new test with the Preview displayed, now displays a message saying that there's no location, instead of making the test a failure immediately.
  • Changed the display of status icons in the Tests list to support the Use simple status icons preference option (that uses just green & red instead of fading colors over time).
  • Moved the Delete menu item from the File menu to the Edit menu, to match the placement in most other apps.
  • Fixed enabling and disabling of menu and toolbar items depending on the selected list items.
  • Fixed a very vexing code signing issue with the Growl framework.

Download Simon 4.1b1 now!

Pack 1.2 released

It's my birthday today! To celebrate, I give you a gift: a redesigned Watch app for Pack!

Like many developers, I was excited by the ability to write an app for the new Apple Watch, so I wrote one before the Watch was actually available: Pack 1.1.

And like many developers (e.g. Marco's Overcast), once I actually had a Watch and used my app on a real device, I realized that my initial design wasn't all that good.

I had thought that scrolling a long list of items to pack, like on the iPhone, would be annoying on the Watch. So I split the packing list up between two screens: a list of categories (or other groupings), where you tap on one to drill down to the items within that group.

In practice, that was cumbersome. Scrolling long lists is actually really easy and fast with the digital crown (or even swiping), and realistically most packing lists aren't all that long, especially as you get towards the end of packing. Having to go back and forth between categories was a pain.

So for version 1.2, I redesigned the Watch app. I collapsed the two screens into one simple list, with headings for groupings.

I also added a Force Touch menu to change the grouping (between by item name, category, or person), and to mark all remaining items as packed (or mark all as unpacked).

I also found, as many others have, that going to the app home screen is less preferred as a way to launch apps. The best way in most cases is to use a Glance from the watch face. So I also added a Glance to Pack, which indicates the number of items still to pack. Now one can simply tap that to launch the full app.

Here are all the changes in version 1.2:

  • Redesigned the Apple Watch app to simplify the layout, with all items in one list like in the iPhone app.
  • Added a Force Touch menu in the Watch app, with buttons to change the arrangement and to mark all items as packed or unpacked.
  • Improved the appearance of the Watch screen when all items have been packed.
  • Now automatically updates the Watch app when making changes in the iPhone app.
  • Fixed a crash when launching the Watch app in some circumstances.
  • Added a Glance on the Watch, as a quick indication of the number of items remaining, and a quick way to get back to the app.
  • The iPhone and Watch apps now arrange by category by default (your selection is still remembered).

Learn more about Pack, or download for free on the App Store.

CocoaConf PDX

At the end of last week I attended my first conference since WWDC07. That's quite the hiatus!

This time it was a much smaller conference: CocoaConf PDX, a small two-day touring conference organized by the Klein family, which visits a number of cities each year.

Now that I'm doing new contract work (in addition to my own apps), I thought it'd be good to stretch myself a little outside my comfort zone with some networking. What better way to start than a small conference in my home town?

Despite being in Portland, I stayed at the conference hotel — mainly because I live about an hour away, and wanted to avoid that commute. The hotel is quite nice, for one by the airport — a nice foyer with ponds and streams, and all rooms are two-room suites. I put in for an upgrade to a "premium" room, and got that, so enjoyed additional benefits like free snacks.

One bit of pre-conference excitement (and hassle for some attendees) was the arrival of President Obama in Portland. I happened to catch Air Force One coming in for a landing, and the motorcade as he and his entourage headed downtown.

The conference provided some nice swag, including a helpful booklet with information about the sessions. Unfortunately, many of the sessions were rescheduled at the last minute, but I still got to attend all of the ones I most wanted to see. Perhaps in the future they'll use an app, so the information can be updated dynamically?

Some conferences are single-track, meaning that everyone attends the same sessions. Others (like WWDC) are multi-track, with a number of simultaneous sessions to choose from. There are certainly pros and cons of each — a single track means more opportunities to meet other people, but could mean having to sit through (or skip) sessions that aren't interesting... while multi-track gives more choice at the cost of fewer personal interactions.

I liked the balance that CocoaConf had: some single-track sessions, and some in three tracks. Plus 15 minute breaks between sessions, and catered lunches and dinner. So there were plenty of opportunities to meet new people, catch up with old friends, and of course learn about the topics that are most interesting (while also expanding one's horizons with new topics).

The circular tables helped with meeting new people — better than the rows of chairs at WWDC, where the only interaction is in the hallways or queues.

Another fun event at the end of the first day was a performance of James Dempsey and the (Conditional) Breakpoints, the biggest group in Cocoa rock.

I recorded a bootleg of their final song of the evening, The Liki Song:

Overall, it was an excellent experience. I'm very glad I attended, and definitely plan to go again next year. I'm also thinking about other conferences that I could participate in... probably not WWDC this year (even the alt conf stuff), but I'm considering the new Release Notes conference in October, as a more business-focused one, though there are many other excellent options.

Simon tip: Simon Extras

Dejal Simon is a powerful and flexible website & server monitoring tool. One of the reasons it is so flexible is that in addition to the many built-in services, filters, notifiers & reports, you can extend it by using or writing custom scripts (or port sessions).

Simon comes bundled with many examples of such scripts; check out the Services, Filters & Notifiers lists and look for the items with a "Script" subtitle. You can inspect and edit those to customize them to suit your needs, or use them as inspiration for your own.

As an additional resource, the Simon site has an Extras page, which lists several more scripts that customers have contributed over the years. Some of which have later been bundled with the app, but some are only available there.

The Simon Extras page is organized by feature kind: Service Scripts, Filter Scripts, Notifier Scripts, Report Templates, and Other Goodies (including a way to add multiple tests, an extended siren sound, and a script to monitor a FTP site). There's also info for developers on writing custom plugins.

I occasionally add new customer-contributed items to the Simon Extras page. For example, yesterday I added a notifier script provided by Carlos Leal to use the third-party Plivo site to send a SMS message, as an alternative to using Clickatell or email.

Installing scripts is easy:

  1. Decompress the downloaded archive, if you browser didn't do it for you;
  2. Launch Simon if not already running;
  3. Go to the Services or Notifiers list, as appropriate;
  4. Click the New toolbar button (or via the File menu);
  5. Choose the Service Kind (or Notifier Kind) button to show the service (or notifier) page.
  6. Choose the Script service/notifier kind, if not selected by default.
  7. Click the Open Script... button and choose the script file.

The script is copied into Simon, so there's no need to keep the downloaded file around after loading it.

If you create or modify a script that others might find useful, please share it! Send me an email with the script attached, along with a description, and I'll be happy to add it to the Simon Extras page.

Pack 1.1.1 released

Quickly following the 1.1 update, which introduced the Watch app, here's version 1.1.1 with an important fix:

  • All items are now selected by default, so you can begin packing immediately.
  • Fixed a crash when adding a new item.

Learn more about Pack, or download for free on the App Store.

Simon tip: enable PHP for scripts

Simon is a very powerful server monitoring tool. One of the reasons for this power is the ability to create custom services, filters and notifiers using a variety of scripting languages.

While languages like AppleScript, Perl, Python, Ruby and shell scripts work out of the box, many people are more comfortable with PHP, commonly used server-side for web pages. But that is not enabled by default in OS X.

It's not too difficult to make it available for Simon scripts, though... if you feel comfortable using Terminal.

Fire up Terminal and enter this command to edit the Apache configuration:

sudo nano /etc/apache2/httpd.conf

You'll be prompted for your password (for the sudo command), then presented with an editor screen.

Press Control-W to search for php. This will move the cursor to this line:

#LoadModule php5_module libexec/apache2/libphp5.so

Delete the leading # to uncomment this line.

Then press Control-O to save the change, then Control-X to exit the editor.

Finally, for good measure, tell the Apache web server to restart:

sudo apachectl restart

That's it! You should now be able to run PHP scripts in Simon.

Pack 1.1 (with Watch app) released

The Apple Watch is available for pre-order and in-store tryout today, and will be delivered starting April 24 for those who stayed up late enough to get their order in quickly. Did you order yours? What did you get? Let me know in the comments.

Personally, I ordered two Watches: a 42 mm for myself and a 38 mm for my wife, Jenn:

Also available today is an update to my Pack iPhone app, to include an Apple Watch extension to help you even more quickly and easily pack for trips.

The Watch app for Pack is very simple: the idea is that you choose what to pack on your iPhone, then you can put the phone in your pocket while actually stuffing your clothes etc into your suitcase, and just tap on your Watch to mark things as packed.

This will be much more convenient. I've used Pack for my own travel for several years (as a pre-release prototype), and while it is quite easy to mark things as packed, having to take my iPhone out of my pocket while I have my hands full of clothing can be a little inconvenient. Being able to just tap my watch will be so much easier.

Since I don't have a Watch yet, I've only been able to test this in the simulator, but Apple has tested and approved it (after a couple iterations of fixes and clarifications), so I'm confident that it'll work well. I'm sure I'll add further features in a future version, based on my and others usage. If you already have a Watch, please try it and let me know what you think!

Here's a brief looping demo of the Watch app in action:


Learn more about Pack, or download for free on the App Store.

About Simon Express and Simon Free

Did you use Simon Express or Simon Free for the Mac App Store? As you have probably seen by now, they are no longer available. I was unable to update them, so announced back in October last year that I'd remove them, which I did when Simon 4.0 was released.

I thought I'd go into this in a bit more depth today.

So, why wasn't I able to update them?

When the Mac App Store was introduced back in 2011, apps could be included without too many modifications or special requirements. So I was happy to provide special editions of my Simon app, which I called Simon Express and Simon Free. The Express edition enabled unlimited tests (at a time when the standard edition had license limits on the number of tests, which is no longer true), but was streamlined to only provide a basic set of services, filters and notifiers, without the ability to add or edit them. Simon Express sold for $59.99. Simon Free was the same, but was limited to only a few tests, and available at no cost. These seemed like useful editions for people who didn't need the full power of the standard edition, and preferred the convenience of the Mac App Store.

But as of June 2012, Apple threw a spanner in the works: they required that all apps in the Mac App Store be “sandboxed” — where the apps can only access their own private folder, among other restrictions.

Since Simon is a powerful tool, capable to monitoring arbitrary folders, accessing network services, running customizable scripts, etc, it wasn't feasible to sandbox Simon without cutting out a lot of functionality, which I didn't want to do. Even the cut-down Express and Free editions would have had to be severely restricted. So it just wasn't doable.

For a couple of years, I left the Express and Free editions on the store, without updates, but I felt bad about them falling behind the standard edition, and so when version 4 came along, it was time to retire those editions.

But where does that leave people who bought the Express edition?

If that's you, you are of course welcome to continue using it (or the Free edition) for as long as you like. But to take advantage of the attractive new user interface and enhanced features of version 4, you'll need a Simon 4 license.

I didn't want to make you have to buy a full license, though. So in version 4 I added support for treating Simon Express as a full version 3 license. If you have Simon Express installed (or have previously used it with your Mac), a “Simon Express” item will automatically appear in Simon's Licenses window. So all you need to buy is a Simon Upgrade license.

Furthermore, if you don't already have data for the standard edition, Simon 4 will automatically recognize and import your Simon Express data, enabling a smooth transition from the old app.

In the months since removing the Mac App Store editions, I don't recall having received any negative feedback about this move. I think most people understand... and frankly the Mac App Store editions were never huge sellers; most people preferred the power and flexibility of the standard edition.

The Mac App Store is a useful tool for discovery of apps that fit within Apple's rulebook, but some apps like Simon, and other third-party ones like BBEdit, Coda and more don't fit in that model. And that's fine.

I will continue to include my apps in the Mac App Store when I can... while also selling directly from the Dejal site.

20th wedding anniversary

Today marks the 20th anniversary of marrying my wife, Jennifer. My how time flies... it seems only yesterday when I posted about our 15th wedding anniversary — read that post from five years ago for the story of how we met, got married, and more.

I wanted to do something special to mark this milestone, so a couple of weeks ago I did something I've been meaning to do for decades: I edited the videotape footage of our wedding into a short movie (about 5 minutes).

It begins with part of a TV news report that aired shortly after our wedding. As that previous blog post described, we met via the internet in an age when that was new and rare, so we were interviewed by local TV and newspaper reporters.

The movie then has clips from the ceremony and reception, which were both held near the beach at one of our favorite spots, Long Bay Beach in Auckland, New Zealand. It concludes with some scenes from our honeymoon in the credits.

Take a look:

20 happy years, full of love and adventures. Happy anniversary Jenn; I love you!

Simon tip: reorder filters, notifiers & more

One of the many enhancements in Simon 4 is the ability to rearrange the order of filters, notifiers, reports and auto pause times while editing a test.

Before, the only way to reorder them after adding was to remove and re-add, but now you can change the order very easily. Simply click and drag anywhere outside a control to move a filter etc to a new position.

Here's a looping video example:

$Cashtag

This morning I saw a blog post by Casey Liss (of ATP and Analog(ue) fame) about the new Square Cash service.

The general idea is to reduce the friction on making payments. You've probably seen or used the Square card reader in indie coffee shops etc. This new service appears to take it to the next level, only requiring a link (similar to a hashtag, hence the wacky name) to initiate a payment. When you go to a $Cashtag page, you're presented with a big field to enter a dollar amount, and fields for a debit card number and an optional note.

It's easy to sign up to receive money, too, via an Square Cash app for iOS or Android. You can then claim your own $Cashtag.

I have, of course, signed up as $dejal. So if you want to send me some money, feel free to use this. It isn't suitable for buying licenses for Dejal products, but as an extra donation of appreciation, this could be a good option.

It'll be interesting to see if this becomes a popular service.

Thoughts on the Apple event last week

As you may have noticed, Apple held a "Spring Forward" event last week, where they covered a number of topics, including the introduction of HBO Now, ResearchKit, a new MacBook, and provided more information about the forthcoming Apple Watch.

If you missed it, you can watch the event on Apple's site, or see an excellent live-blog summary below the video. (From where I obtained most of the images in this post; credit to Apple.)

It's been a week, and I'd like to share some thoughts.

HBO NOW

The first news that caught my attention was the announcement of HBO NOW.

My wife and I are "cord cutters" — we don't have a cable or satellite TV subscription, and rely on Apple TV for most of our TV content, along with Netflix streaming and such. As such, we have long bemoaned the fact that HBO didn't offer a way to pay for their excellent content without a cable subscription. HBO NOW is the answer we've been waiting for: the ability to get HBO shows without a cable subscription, right on our Apple TV.

This is an excellent deal for Apple, too, with a three month exclusive period, that should drive many more people to consider an Apple TV... helped along by a price drop to just $69 for the hardware. I am a little disappointed that they didn't bring out a new version of the Apple TV yet, but the current unit is okay, if getting a bit long in the tooth.

Apple Pay

Next was some talk about the iPhone, and Apple Pay. I only recently upgraded to an iPhone 6, and haven't encountered anywhere that accepts it in the wild (I don't tend to frequent such places), so haven't yet tried it. It does seem like an excellent feature, though, and I'm glad more and more retailers are gearing up to accept Apple Pay.

ResearchKit

A big surprise announcement was ResearchKit, a framework for collecting information to help with medical research. They spent about 15 minutes talking about this, and while it may not have a significant impact on Apple's bottom line, this is yet another sign of the new Apple under Tim Cook: more focused on improving the world, not just through great customer-focused products, but in improving life and health for humanity in general.

It's impressive that it has already had a big impact, with signups for a ResearchKit-powered study vastly outstripping the usual approach.

MacBook

Before the event, there had been rumors circling for quite a while about a new MacBook, and they proved pretty accurate. This new MacBook is clearly a sign of things to come — the logical evolution of taking the iPad technology and bringing it "back to the Mac" once again.

This new computer has several significant changes. It is of course thinner and lighter than existing Air models, as is Apple's wont... perhaps to a fault. It also has a retina display, which is a welcome addition in such a tiny laptop. I use a several-years-old iMac as my desktop machine, and last year's MacBook Air as my laptop, neither of which has retina. My eyesight perhaps isn't good enough to tell the difference, but I certainly do enjoy retina displays on my iOS devices, so look forward to upgrading a retina Mac one day. I won't be getting this edition, though, since I just bought my Air last year.

The new MacBook also features a new keyboard, with a new switch mechanism and better LED backlighting. I haven't tried the new keyboard, so I don't know whether I'll prefer it over the previous ones, but I hear that it doesn't take long to get used to it.

Also on the input, there's an impressive new Force Touch trackpad, that does away with the physical clicking, replacing it with a taptic feedback that apparently feels just like a click, while offering more customizable options.

I don't want to reiterate all of the changes, so I'll just briefly mention the impressively shrunken logic board, without a fan, and layered batteries. It really seems like an iPad inside a Mac.

Another way it's like an iPad is the reduction of ports: just a headphone jack and a single USB-C port. This was perhaps the main focus of rumors before the event, with lots of discussion on the likes of the Accidental Tech Podcast and elsewhere. Many people were skeptical, and critical of the product after the introduction, but I'm not one of them. As I mentioned, I have a MacBook Air, but it is purely a secondary machine — I use it when traveling (sometimes; often an iPad is enough) or when working on the couch some evenings... or from a hammock in summer.

I almost never plug in anything to this machine, other than power when I stop using it. The battery lasts longer than I typically use it, so rarely need to plug in to recharge, and I don't need to connect an external keyboard, screen, or other devices. I can certainly understand that people who use it as their primary machine in a desktop situation might have issues with only having one port... but for those people I don't think it's unreasonable to plug in a hub like Apple's new one (albeit overpriced) or the inevitable third-party ones. That seems like it'd be more convenient, instead of having to deal with multiple plugs every time you want to take the computer away.

But what do I know... that isn't my use-case, and I suspect that Apple envisions people using a laptop as their primary machine to go with the Pro edition instead. I do have some experience with this scenario, though: before I got my iMac, I did use a MacBook Pro 17" as my primary machine, along with an external display... but I preferred to use the built-in keyboard and trackpad, so still didn't have all that much plugged in.

Apple Watch

Was there anything else? Oh yeah, some watch gadget.

The coverage of the new Apple Watch seemed almost like an afterthought... almost an hour into the show, and only taking about half an hour. But that's not unreasonable, since this served mainly as a reminder of the introduction, and an update to answer some questions. Little details like pricing and availability.

Prior to this event, Apple had only announced the "starting" price of $349. There were wide-ranging guesses on where the other models would end up, with John Gruber of Daring Fireball making what many people thought were wildly high predictions on the gold Edition model pricing, initially around $5,000 then later predicting $10,000 and up to $20,000. Which turned out to be very accurate, with the Edition models priced between $10,000 and $17,000. I'm not a watch guy, so those prices seem way more than I'd ever pay for a watch, but I certainly understand that in the high-end luxury market, those prices are very reasonable.

For the middle model, confusingly just called Apple Watch, there was perhaps less of a range of expectations, and the pricing that eventuated seems reasonable, given the $349 starting point for the Sport model: $549 for a sport band up to $1,099 for a black link bracelet.

I'm definitely excited about the Apple Watch. I plan to get one, if only so I can test the Watch app for my Pack packing list app (business expense!). I haven't worn a watch in years, but I think that will be changing soon, as it no doubt will for many people.

I'm not sure which exact model I'll get. Definitely a 42 mm Sport model, though — 42 as I have large hands, so the 38 mm wouldn't fit me, and Sport because I'm budget-constrained, and not really a fashion person. I'm leaning towards the Space Gray case, but might be okay with the silver aluminum case with green band, too. The other colors don't really do it for me. I'd like to try on some of the other band options as a future expansion option... particularly the Milanese Loop and Leather Loop. But I think I'll be happy with the rubber (excuse me, "fluoroelastomer") band.

Simon tip: check notifiers

I've recently had a couple of queries (via email and the Simon Forum) about checking if a notifier is working, so that seemed like a good blog topic.

Simon is a powerful app. One of its many features is the ability to create custom notifiers, the mechanism for informing you of changes or failures on the tests. Naturally, when you configure a new notifier, or edit an existing one, you want to make sure that it is set up correctly.

This can be done very easily. When showing the Notifiers list, you can simply select the notifier you want to check (as you probably already have if you're editing one), and click the Reload button in the toolbar, or choose the File ▶ Notify Now menu command.

The selected notifier will then be used, just like when used with a test, except that placeholder values will be used for any variables (since there isn't a test in this case).

For example, here's a Notification Center notification, showing placeholder values (click to see full-sized... and yes, I do have rather a lot of system menus!):

Pack for Apple Watch

The Apple Watch will be available soon... how soon we should learn on Monday with their special event. So lots of developers have been announcing apps to run on the Watch — see WatchAware's excellent site for a good showcase.

I don't want to be left out from the fun. So a few weeks ago I spent a few hours over a weekend adding an Apple Watch extension to my latest iPhone app, Pack — a simple app to help you quickly and easily pack for trips.

Apple isn't accepting Apple Watch apps yet, but I'll be ready when they do. The Watch app for Pack is very simple: the idea is that you choose what to pack on your iPhone, then you can put the phone in your pocket while actually stuffing your clothes etc into your suitcase, and just tap on your Watch to mark things as packed.

This will be much more convenient. I've used Pack for my own travel for several years (as a pre-release prototype), and while it is quite easy to mark things as packed, having to take my iPhone out of my pocket while I have my hands full of clothing can be a little inconvenient. Being able to just tap my watch will be so much easier. And yes, you can bet that I'll get my order in for an Apple Watch as soon as pre-ordering is open. (I haven't finally decided which one, but probably the Space Gray Sport model, or maybe one with the green sport band, since green is good.)

Here's a brief demo of the Watch app in action:


Want to try Pack? You can download it for free from the App Store.

Simon 4.0.3 released

Another small update of Simon, to version 4.0.3.

This update is notable as the first to be delivered via the Sparkle update framework, for people on 4.0.2 (where that was introduced). Hopefully it'll work properly. :) (Yes, seems fine; I just tested it.)

Changes in this release include:

  • When the Show the Simon icon in the Dock preference is turned on, its status is now immediately updated.
  • If a password has been set to access Simon, the unlock panel is now shown without the Monitor window.
  • Fixed a hang in the Twitter notifier when typing in the message text area.
  • Fixed some cosmetic Console warnings with the notifier options editor.
  • Fixed an issue that prevented the MySQL helper from starting.
  • Fixed the helper to launch Simon on login.

If you have Simon installed already, you can get the update via the SimonCheck for Updates... command in the app, which will install it for you; no more need to download manually. You can even check the box to have future updates installed automatically if you wish.

If you don't have Simon yet, you can download Simon 4.0.3 now!

SmileDial & Valentines discontinued

I don't like to discontinue apps, but sometimes it's necessary, or just a matter of accepting the inevitable.

My first two iPhone apps, SmileDial (written in 2008) and Valentines (written in 2009) haven't been updated for years. They did what they were designed to do, so didn't really need updates. Though to be frank, they never made much money or had many downloads, so I simply couldn't justify the time to update them.

I haven't even run them myself in ages, but I assume they still work, albeit not using the modern appearance and screen sizes.

So today I officially discontinued them, and made them free on the App Store. I'm not going to remove them from there or my site: if you find them useful, you're welcome to download and use them at no cost. Just be aware that they won't get any updates, and I can't really provide any support for them (though if you ask, I'll certainly try to answer).

DejalIntervalPicker: a custom Mac control similar to NSDatePicker, but for time intervals or ranges

Another open source project for developers.

DejalIntervalPicker is a custom Mac control similar to NSDatePicker, but for time intervals or ranges.

This project was started several years ago for Time Out 2, but got put aside while I worked on contract projects. I've just finished it off and released it for others to enjoy. It will be making an appearance in Time Out 2 as of the next alpha release.

Requirements

  • OS X 10.10 or later recommended, but should work back to 10.7.
  • Objective-C language.
  • ARC.
  • Dependency: the DejalObject project.

Features

  • A custom control with an amount or amount range, units, and stepper.
  • Like NSDatePicker, editing components separately, with a stepper.
  • Can set minimum and maximum amounts.
  • Can get/set the interval as a DejalInterval, as individual values, or as a NSTimeInterval.
  • Can have either a single amount or a range of amounts.
  • Can optionally filter the range to ensure the first amount is smaller (or equal to) the second one, or vice versa.
  • Can control which units to include.
  • Can navigate between components via Tab and Shift-Tab and left/right arrow keys, or clicking.
  • Can type amounts just like in the date picker, and units with auto-completion.
  • Can increment and decrement amounts and units via up/down arrow keys, +/- keys, or the stepper.
  • Can increment/decrement in steps of 5 via Shift/Option/Ctrl and up/down arrow keys, or Page Up/Down.
  • Can go to the first/last valid values via Home/End.
  • Can display a drop-down menu of suggested legal amounts or units via the spacebar or clicking on the selected value.
  • Supports regular, small and mini sizes.
  • Supports properties, key-value coding, and bindings.
  • Supports IB_DESIGNABLE and IBInspectable, so the picker can be configured in IB.
  • A demo project is included.

Usage

  1. Include the DejalIntervalPicker.h and DejalIntervalPicker.m files in your project. Also include at least DejalObject.h, DejalObject.m, DejalInterval.h and DejalInterval.m from the DejalObject project.
  2. In Interface Builder for your xib or storyboard, drag a custom view to your view or window.
  3. In the Identity inspector, change the Custom Class of the view to DejalIntervalPicker.
  4. In the Size inspector, add a Placeholder Intrinsic Size of 150 width and 22 height if using Auto Layout, or set the view to that size for auto-resizing.
  5. In the Attributes, configure the desired attributes like the using range, initial amounts, and which units to include.
  6. In your controller, you can also configure the picker via methods like usingRange, includeForever, firstAmount, and others; see the demo project for examples.
  7. Populate the picker value by setting the amount(s) and units, or setting the interval from a DejalInterval instance.
  8. Get the picker value via the same properties: either amounts(s) and units directly, or the interval instance.
  9. See DejalInterval for several useful methods and properties, e.g. to get a string representation of the interval.

You can get the code and more information from the Dejal Open Source page.

DejalObject: an abstract data model class that can represent subclasses as dictionary or JSON data

DejalObject is an abstract data model class that can represent subclasses as dictionary or JSON data for saving to disk or over the network.

Included are DejalColor, DejalDate and DejalInterval concrete subclasses.

They work on both OS X and iOS.

Features

  • DejalObject: This is an abstract subclass of NSObject that adds methods to represent the receiver as a dictionary or JSON data, load default values, track changes, enumerate an array of DejalObject instances, and more.
  • DejalColor: A concrete subclass of DejalObject to represent a color (for OS X or iOS), enabling it to be stored in a DejalObject subclass.
  • DejalDate: Another concrete subclass to represent a date, primarily so it can automatically be represented as JSON.
  • DejalInterval: A subclass to represent a time interval or a range of intervals, including an amount and units, with methods to represent the interval or range in various ways, including as human-readable strings (see also the DejalIntervalPicker project for OS X).

A demo project is included, showing a subclass of DejalObject to store various data types.

Usage

Include at least DejalObject.h and DejalObject.m in your project. Include the DejalColor, DejalDate and/or DejalInterval files if those are needed.

Add a new class that inherits from DejalObject.

In the header, you only need to define properties to store, e.g.:

@interface Demo : DejalObject

@property (nonatomic, strong) NSString *text;  
@property (nonatomic) NSInteger number;  
@property (nonatomic, strong) DejalColor *label;  
@property (nonatomic, strong) DejalDate *when;

@end

In the implementation, override -initWithCoder: and -encodeWithCoder: if you need to support coding (secure coding is supported in DejalObject).

Override -loadDefaultValues to populate default values to each of the properties. A version number can be assigned (via DejalObject’s version property) to enable upgrading later, e.g.:

- (void)loadDefaultValues;  
{
    [super loadDefaultValues];

    self.version = DemoVersion;  
    self.text = @"Foo";  
    self.number = 12345;  
    self.label = [DejalColor colorWithColor:[NSColor blueColor]];  
    self.when = [DejalDate dateWithNow];  
}

Finally, override -savedKeys to indicate which properties should be automatically included in the dictionary or JSON representation, e.g.:

- (NSArray *)savedKeys;  
{
    return [[super savedKeys] arrayByAddingObjectsFromArray:@[@"text", @"number", @"label", @"when"]];  
}

A DejalObject subclass can be represented as a NSDictionary simply by invoking the dictionary property on it, or as JSON via the json property. That can then be saved to disk or the user defaults, or passed over the network.

Those properties can also be set, or a new instance can be created via +objectWithDictionary: or +objectWithJSON:, or an instance with default values via +object.

DejalObject instances automatically track changes, with a hasChanges BOOL property indicating that something has changed (so may need to be saved). There is also a hasAnyChanges property that recursively enumerates the properties and any other DejalObject instances in them, e.g. if the color is changed in the above example.

After saving, you should invoke -clearChanges to reset the change flag.

You can get the code and more information from the Dejal Open Source page.

Syndicate content