There’s a really telling thread active on the cocoa-unbound mailing list right now, regarding the difficulty in grasping how to structure applications in Mac OS X, especially as compared to its sibling iOS, and the materials that are available, a subject with which I’ve become quite familiar as I hack on STRIP for Mac OS X:
When I create a new Rails application or Ruby Gem, there’s a clear, predefined application structure. Its obvious what things go where. It’s the same structure every time,
When I first created new iPhone projects, picking a “Navigation-based app” or such like gave you all the structure you’d really need for that type of app. You could see exactly where the VCs lived, how they hooked up to NIBs and how they talked to each other. I don’t need the templates now, but they were very instructive in the beginning.
I’m missing the same thing for Mac applications.
Exactly. List users are starting to add their suggestions for reference material and tutorials, some good resources there. But really, we could use some better, more comprehensive materials from The Source for Mac OS X. The WWDC video sessions are invaluable, the small app examples are great, the API documentation is fantastic, but we devs really could use some beefier, more complex, real-world reference materials.
Update: It’s not really a how-to document, but I did get a lot out of Matt Gallagher’s article, The design of every Mac application.
In working on Strip for Mac OS X, I came across a scenario in which I wanted to get the bottom bar buttons on an NSWindow
to follow the left-margin of panes about them in an NSSplitView
with which they are associated. That sounds like a mouth full, so I’ll use a picture to illustrate, it’s an idea I’m looking to borrow from Apple’s Address Book application (click image to embiggen):
What I’m trying to suggest with the annotations I’ve made on the image is that the [+] button under that middle pane (highlighted in green) will move as the left margin of the pane is moved, either by the user, or by the window being resized—which cascades down to the subview being resized, since the split view is basically the entirety of the window’s contents.
In any event, I wasn’t sure how to hack this out and didn’t see any examples out there, so I put one together. There might be a better, faster way of handling this, perhaps by responding to NSView notifications about a change in frame, but here I just used an NSSplitViewDelegate
method that fires every time subviews are resized (thus, every time the margins of the panes might have been adjusted by a resize or a divider moving). Sample project is here on Github, but this is the meat of it, in the NSSplitView’s delegate:
// gets call after the NSSplitView is resized OR after the divider(s) are moved
- (void)splitViewDidResizeSubviews:(NSNotification *)aNotification
{
[self repositionBottomBarButtons];
}
- (void)repositionBottomBarButtons
{
// we don't actually have to do anything for the left-most button and the left pane
// because we've got it pegged in IB to maintain it's position in relation to the
// window's bottom and left bounds
// first tell the superview that it will need to redraw the frame we'll be moving
NSRect oldFrame = [rightButton frame];
[[rightButton superview] setNeedsDisplayInRect:oldFrame];
NSPoint newOrigin = rightView.frame.origin;
NSRect newFrame = NSMakeRect(newOrigin.x, oldFrame.origin.y, oldFrame.size.width, oldFrame.size.height);
[rightButton setFrame:newFrame];
[rightButton setNeedsDisplay:YES];
}
And there we go, button now follows the pane’s margin, moves nice and smooth.
It has come to our attention that there is a potential for inadvertent loss of data in STRIP for customers who have purchased a new iPhone to replace an existing one. This may also affect other iOS devices such as iPod Touch and iPad.
When setting up a new iPhone in iTunes, iTunes offers to restore the data from your old device on to the new one. It would seem that in some cases the process appears to have been completed successfully, but the user later discovers that while Contacts and data from other default applications is transferred successfully, STRIP and other downloaded applications are missing their data. Some users have found (including us personally) that doing a second “Restore from Backup…” operation completes the migration successfully.
However, some users don’t notice the failed migration right away, and have at times discarded the old device (thus losing access to its copy of Strip’s data), or have synced their iPhone with iTunes since the initial Restore, which has the effect, in some cases, of wiping out the old backups maintained by iTunes. In that unlikely situation, it becomes nearly impossible to recover the user’s data.
Avoiding the Problem Before You Make the Switch
If you are planning to migrate to a new device or upgrade your iOS operating system, you’ll want to do the following before you make the switch. We’ll go through the various steps below.
- Disable automatic syncing in iTunes
- Turn off encrypted back up (temporarily)
- Take a fresh backup in iTunes, explicitly
- Use Strip Sync to take an independent backup of your data
As always, we are here if you run into trouble, please get in touch.
Disable automatic syncing in iTunes
Make sure your iPhone is disconnected from your computer. Open up iTunes, go to Preferences → Devices, and make sure the checkbox “Prevent iPods, iPhones, and iPads from syncing automatically” is checked.
Turn off encrypted backup (temporarily)
Connect your iPhone (or iPad or iPod Touch) to your computer with the USB cable that came with your device. If iTunes is not running, start it. Once the device appears in the left-hand side of the iTunes window, click on it to bring up the Summary screen. Scroll down to Options, and make sure that “Encrypt iPhone backup” is not checked.
Take a fresh backup in iTunes, explicitly
Every time you sync, iTunes will take a fresh backup, but it doesn’t necessarily keep that backup around for later. Doing it explicitly will keep the backup around for later in case we need to do a Restore.
In iTunes, with your phone still connected, right click on your phone’s icon and name in the left-side view of iTunes. In the menu that comes up, select “Back Up” to initiate a fresh, unencrypted back up.
The process may take a few minutes to complete.
If you had turned off encrypted backup in the previous step, you can now turn it back on.
Use Strip Sync to take an independent backup of your data
To ensure that you can have an independent backup outside of iTunes, we’ve published a free companion utility for Mac OS X and Windows called Strip Sync. It is important that you download and configure Strip Sync on your desktop. Once installed you’ll be able to sync your data off your iPhone and into Strip Sync over WiFi.
You can download Strip Sync for free over here: http://getstrip.com/strip-sync
Be sure to follow the setup instructions for your operating system:
Strip Sync works over WiFi on your home or office. If you have problems syncing the most likely cause is a firewall or network issue, and a good first step is to ensure your workstation firewall is disabled or at least allowing incoming connections. Do get in touch with us if you need help.
There’s an updated version of Codebook in the App Store, v1.3.0, which fixes a bit of a nuisance bug with regard to timestamps.
We’ve received a few requests recently to provide an online or cloud-based backup/sync solution for our password manager Strip, in particular as to whether we plan to add an integration with Dropbox, so we figured now is a good time to provide a statement with regards to what direction we’re going.
We do not have plans to provide an integration with Dropbox for Strip at this time. While we agree an online backup would a really cool and useful feature, we’re uncomfortable with tying a core part of the product to another service that might change without consultation. That’s not to say anything at all about the utility or stability of Dropbox (it’s a really useful service done very well), but decisions made at Dropbox will always be out of our control.
Any online backup would require that the database file be stored remotely in an unknown location, with unknown security risks. That scenario makes us and many of our customers nervous, so we are reluctant to move in this direction without serious planning and risk evaluation.
We’ll continue to investigate the possibility of an online backup for Strip, but in the mean time, Strip can be backed up to the desktop with Strip Sync, providing multi-device replication. Our implementation requires authentication, and the files are always encrypted and secured on your local computers.