Archive for the ‘Apple’ Category

CoreData + iCloud, Buyer Beware

Monday, February 4th, 2013

Back when iOS 5 was released, it was introduced having support for Apple’s new “cloud service”, iCloud. Dutifully, Apple provided developers with an API to store and access data in iCloud, and their usual Apple way, attempt to implement the “heavy lifting”.

We can now store small bits of key-value data, quickly and easily, to be shared amongst our devices.

Additionally, documents can be “magically” store with minimal additional effort from previous document support.

Finally, the coup-de-gras, is the ability to sync our Core-Data backed data, again, with only the smallest number of changes to current implementation.

To help its developers along, Apple provides sample projects and code snippets to demonstrate the ease by which these magical technologies may be easily incorporated.

Even at the latest local CocoaHeads meeting, the presenter puts together a demo that shows the wonders of using CoreData plus iCloud, and we all applaud in approval.

Others might have disagreed, however.

  • No Identity apps had their tush bitten by a released application.
  • Notable Mac developer, Bare Bones Software (at this time) is still struggling with getting their app, Yojimbo, to play nice with iCloud (although, in all honesty, they might have come from a slightly different direction with converting the now defunct MobileMe support to iCloud)

Not trying to be a nay-sayer, but this is not comprehensive list of complaints we have heard. We haven’t made the transition on Wooly Tasks yet, so we are not speaking from first-hand knowledge, but best to go into the effort with eyes-wide open.

An ARC Transition Tale

Tuesday, July 10th, 2012

If you are not a software developer, this post will probably of less interest to you. Otherwise, please read on…

Recently, I updated Wooly Tasks to use Automated Reference Counting (ARC). The transition from a non-ARC project to an ARC project is fairly straight forward, and mostly automated by Xcode 4. ARC allows the developer to worry less about Cocoa memory management rules, and instead focus on their object graphs and creating great software. ARC is a handy tool, but you now a have some new rules to learn (although, in truth they are probably less confusing as a whole than the old rules). One that is important is object lifespans. Essentially, this means the LLVM compiler can decide to release an object that it deems unused at any moment within the body of the code. We’ll see what kind of ramifications that presents soon.

It’s all fun and games until you shoot your eye out…

Once I had successfully transition (i.e. it compiled and linked), I tested Wooly Tasks using the simulator. To my delight, everything still worked as expected. OK, time to build and install on a device (in this case my iPhone 4S running iOS 5.1).



Crash. What the #^$#!!

Check with the Simulator again. Fine.

Back to the iPhone. Crash. Gah.

Unfortunately, it crashes due to an autorelease object, so there is no stack dump to figure out what the object is that is causing the issue (this is not entirely true, you can look at the crash log in Xcode, and this would give you plenty of clues…I didn’t think to look there first, unfortunately — lesson learned). All I get is a cryptic console log exception message stating:

“[Not A Type isEqual:] sent to deallocated object 0x….”

Well, huh.

Debugger spelunking time.

So, I started running it in the debugger and setting breakpoints starting from the first UIApplication delegate call and on down the line until I narrow it down to the setting up of the first view controller and displaying its view. Eventually I found the offending code (for brevity, I have left out the values, they were irrelevant to the issue, as is the particular color creation method):

CGColorRef color = [[UIColor colorWithHue:saturation:brightness:alpha:] CGColor];
self.layer.shadowColor = color;

Do you see the problem? Clang’s document on Automatic Reference Counting and lifetime semantics states:

By default, local variables of automatic storage duration do not have precise lifetime semantics. Such objects are simply strong references which hold values of retainable object pointer type, and these values are still fully subject to the optimizations on values under local control.

We have done the equivalent of:

UIColor *uiColor = [UIColor colorWithHue:saturation:brightness:alpha:];
CGColorRef cgColor = [uiColor CGColor];
self.layer.shadowColor = cgColor;

LLVM has every right to deallocate the UIColor object immediately after obtaining the CGColorRef from it, since by all accounts, it is no longer be used. This would then invalidate the data referenced by the cgColor local variable. When we set the shadowColor for the layer, we are potentially (in this case, we definitely were) stuffing an invalidated (but not nil’d) object value into it.

The Fix

The simplest solution was to rewrite the code like:

UIColor *color = [UIColor colorWithHue:saturation:brightness:alpha:];
self.layer.shadowColor = [color CGColor];
LLVM compiler will not be able to insert a release between accessing the CGColor and assigning it to the shadowColor.
And here you thought you could forget all those pesky memory rules.

Xcode 4: Renaming projects

Sunday, January 22nd, 2012

Xcode 4.x is a great leap forward for iOS and Mac OS Developers. Many thanks should be expressed to Apple and its engineers for their hard work in putting together such a toolset. If you were used to Xcode 3.x’s way of doing things, then you might find yourself wondering how to do various operations that seemed to have disappeared. Renaming a project one such feature that took a while to relocate, so I am sharing how it is done in Xcode 4.x. It is much better to rename the project through the mechanism provided by Xcode than trying to rename the project file via the Finder. I have done so in the past, and it wrecks havoc on the project settings.


Step 1. Select the project in the Navigator (left side of Workspace. Command-1 to reveal).




Step 2. Make sure the File Inspector is visible. (right side of Workspace. Command-Option-1 to reveal, or third most button in the view button cluster).


Step 3. Under Identity, you will see the Project Name text field.

Change the name of the project to the new desired name.

A drop down sheet will appear when you exit the text field. It will be showing you what will change, giving you one last chance to back out…sort of. This last chance inquiry is for settings that are derived from the project’s name (target name, product name, prefix header, etc.).

If you say “Don’t Rename”, the project itself will still be renamed, but the auxiliary portions won’t. This could potentially leave things in an unsavory state. I imagine this is a bug, and as a matter of fact, even had Xcode crash more than once when testing out renaming of the project, but not going through with it.

You may also be asked whether you want to take a Snapshot prior to preforming the renaming. This is entirely up to you and your risk tolerance.

That about covers it. Happy programming!



Steve Jobs 1955-2011

Wednesday, October 5th, 2011

Steven Paul Jobs 1955-2011

Today, Steve Jobs, an amazing man in his own right, and an undisputed visionary, passed away at age 56. He led an amazing life, did amazing things, and created several amazing companies (NeXT, Pixar, Apple). He, more than many others in history, has done more to positively influence people’s lives and livelihoods.

I am selfishly sadden that I never got to personally meet Steve, even though I have admired him ever since I brought home my first Apple product, an Apple ][+, nearly 30 years ago. That purchase, earned by a summer of construction work during the summer between my sophomore and junior year of high school, led me to the path of developing software as a profession.

When I lived and worked in Sunnyvale, in the early 1990’s, I use to ride my bicycle up Foothill Expressway and into Palo Alto (usually stopping at Stanford with a book to read and soak in some of the sun). Often, before heading home, I would ride into the neighborhoods of Palo Alto, knowing that Steve Jobs had his house somewhere there. I was hoping that I might have a chance encounter with him, or at least see his house from the street. I never did, and having seen pictures of his house, I’m pretty sure I was in the wrong neighborhoods, but it sure was fun trying at the time.

Other people who may or may not have made their marks on the world, including noted civil rights leader Rev. Fred L Shuttlesworth, died on the same day. This doesn’t mean that Steve was better than these other people. We could all learn from their lives. Steve gave us the gift of showing that hard work, breaking the status quo, and doing things a bit differently is a Good Thing.

May his family find comfort somehow in knowing he is no longer suffering, and is at peace. May the world come together and embrace his propensity of creative thinking and attention to detail.

Rest In Peace, Steve. You inspired me for 30 years, now we continue forth and carry your message into the future.


“Stay Hungry, Stay Foolish”

WWDC 2011 Keynote

Monday, June 6th, 2011

No, I’m not there. 🙁 As of the time of this writing (9:30am WWDC time), the energy is palatable for this year’s event even 600 miles north of San Francisco (one of my all time favorite places to be) up in Portland.

We already know that Lion (Mac OS X 10.7) will be “announced” (it already really has been, just not the minutia), iOS 5 (same…it exists, no real details), and iCloud (more heavily covered…ie streaming music and a music locker, but free MobileMe services too?). What we don’t yet know is what the “Just one more thing…” is all about.

We know there is something afoot due to this image taken inside Moscone West this morning: (image no longer available)

I originally speculated with @CocoaGeek that this might just be the banners seen already that read “Lion + iOS 5 + iCloud = WWDC11”. However, as @CocoaGeek correctly pointed out to me, this doesn’t make a lot of sense since those have already been announced, even if no details have been given.

So, at 10:00 am (WWDC time) we’ll begin to know that all this is about. All I know is that 2011/2012 is going to be very, very good years to be an Apple developer.

Will update as more information flows in….

10:00 am update…

Mac OS X Lion “announced’ along with 10 new features (out of a claimed 250) being showcased:

  1. Multitouch gestures with trackpads
  2. Full screen apps (meant for smaller screen laptops/devices)
  3. Mission Control (kind of like Exposé + Spaces). A simple gesture gives you a bird’s eye view of everything on your system.
  4. Missed this one…will add it once I can get the skinny on it. Ah, I guess it was the Mac App Store. Nothing terribly new, other than it has become the number one channel for buying PC software.
  5. Launchpad, a new launcher a’la iOS Springboard for the Mac OS. Apparently also employs a sandboxing scheme.
  6. Resume (Nice!) allows you to return to the exact state of the app and its documents
  7. Auto Save (enough said)
  8. Versions… version control for everyone (I wonder if it is based on Git? :-)). Time Machine for all your documents. Who doesn’t want/need that?
  9. AirDrop (Yes!) peer-to-peer WiFi based network (what?! No bluetooth love!?)
  10. with updated UI and other enhancements.

Available only via the Mac App Store, and only $29.99!! Wow!

10:34 am update…

OK, that’s the 10 features they chose to show-case. Looking forward to hearing what is in iOS 5. iCloud being saved for last, so I expect great things. Plus, don’t forget our “One last thing…”

iOS 5 Top 10:

  1. Notifications. Yes! This was a mess and very intrusive. Now can swipe down from top to see current list of notifications.
  2. Newsstand, iBookstore for magazine and newspaper publishers. Nice idea. I wonder how many Indie developers this impacted?
  3. Twitter integration! OK, wow. Explains a few moves made by Twitter over the past few months, particularly with authentication and third-party app support. Again, how does this impact the Indies?
  4. Safari (updated). Reader support (as can be found in Safari 5 for Mac), very nice. Reading List, for saving for later. Tabbed browsing, on the iPad anyhow (Excellent!).
  5. Reminders (Hmmmm… Wooly Tasks killer I think). Lots of interesting features that I had also thought of adding, but Apple has 1000s of more engineering resources than I do, so they beat me to the punch. Ah, the nature of the business. We’ll see.
  6. Camera (updates). Lots of enhancements, mostly in making taking a picture faster and easier. Using the up volume button to take a picture will be really nice. Rule-of-thirds guides. Built-in editing of photos.
  7. Mail (updates). More composing and editing options, in particular, rich-text formatting (YES!). Introducing a new keyboard layout that is thumb-centric and available system-wide.
  8. PC Free…no more tethering!
  9. Game Center
  10. iMessage, new messaging service for all iOS devices. Yay! iChat for iOS

AirPlay mirroring.

iTunes syncing wirelessly.

Available Fall 2011.

11:20 am Update…

iCloud. The Digital Hub that Steve Jobs talked about in 2001 has now moved to “the clouds”. iCloud stores your content “in the cloud” and wirelessly pushes it to all your devices.

MobileMe “wasn’t our finest hour”, but “we learned a lot”. MobileMe is dead. iCloud will subsume all the services of MobileMe, but everything is rewritten from the ground up, and the best news of all…

…it’s FREE.

iCloud is invisibly integrated into apps that need synching of data, such as Mail, Contacts, Calendar, etc. Wireless back-up (a’la “PC Free” feature above). Also backup purchase of iBooks, music, apps, camera roll (on iPhone), etc.

iCloud also has a feature called “Documents in the Cloud” for syncing Pages, Numbers, and Keynote documents. For developers, there will be an iCloud Storage API. And, it will work with PCs as well.

iCloud allows photos taken on your iPhone to automatically be synched onto your iPad. No more needing to tether, sync, sync, sync, … Up to 1000 images stored on your iOS devices, and anything you want to permanently keep, you just need to move into an album. Photos remain for 30 days, so grab them or lose them. There is a Push Photo Stream builtin to camera rolls which is where the syncing takes place.

iCloud is WiFi only due to immense amount of data being pushed. When carriers can reliably offer 4G or greater, then I’m sure it will move to the celluar network.

Finally, there is now iTunes in the Cloud. Buy a song, sync with all devices, automatically.

10:50 am update…

Just in time for “One more thing…”

iTunes Match. For those songs that you ripped from your personal CDs. iTunes will scan your music for non-iTunes purchased music, and voila, your songs are automatically in the cloud. No uploading needed, if they already exist in the iTunes Store. For the rest, they are uploaded. This is the rumored “Music Locker”, and it costs $25 a year (but if you had MobileMe, you still $74 ahead).



Apple’s Magic Trackpad

Wednesday, October 20th, 2010

After completing my contract project for version 1.0 of Deep Dish Design’s iPad product, my business manager/advisor gave me permission to make some capital improvements. Namely, to invest in a new input device… Apple’s Magic Trackpad.

Not a purchase of necessity by any  means.

Actually, as nice as the trackpad is on my MacBook, I’m not a big fan of using it unless I happen to be traveling light, or forgot to bring a mouse (usually the case).

But, guess what? I have really enjoyed using the Magic Trackpad. I have yet to reach for my well used Magic Mouse. I think part of it is that I don’t have to reach in front of the keyboard to actually use it. It sits to the side, wherever I want it, and is ergonomically “just right” in term of reach and placement. It also seems less “twitchy” than the Magic Mouse when it comes to zooming in Google Maps or dynamically resizing content in a browser window. Plus, no false zooms like I get with the Magic Mouse – so, incredibly annoying.

Definitely a worthy investment so far.

iPhone OS 4.0

Thursday, April 8th, 2010

Way to go Apple! Nice major OS update! Today, Apple took the wraps off of iPhone OS 4.0. There are a lot of additions to this version, some strictly interesting to the user, and many very interesting to developers. Without a doubt, the iPhone OS has taken a quantum leap forward, and shows that Apple is not resting on their laurels.

Suffice it to say, the next time you hear or read about how another smartphone OS developer is going to put the hurt on Apple, just remember how Apple responded with this stellar (soon to be) release of the OS. Innovation is live and well at Apple.

Some notable highlights as we see it. More later I’m sure after we get our hands on what is available to us as developers.

Multitasking: Enough said. Thank you Apple.

Calendar Access: Finally we can gain access to the calendar, which should make for a more powerful experience when we incorporate that into Wooly Tasks.

Local Notification: Like Push Notification in 3.0, this is local to the user’s iPhone. What does this mean? Finally we can resurrect alarms in Wooly Tasks, among other things!

Folders: Did you know you could only install 180 apps onto your iPhone? Actually, less, since you have several Apple supplied, permanent apps. Now you can organize your applications into folders, and be able to store 2160 apps on your device. Nice.

Game Center: Incorporating built-in social gaming network. Leaderboards and “matchmaking” to hook you up with other players. Why is this interesting to us? See our motto. 😉

That’s all for now. We are extremely excited to get out hands on the developer preview of OS 4.0, and really pick apart what it provides and plan for adopting the technologies. It is a very exciting time to be a user of the iPhone, iPod touch, and iPad, and even more exciting as a developer for the platform.


iTunes App Store Ratings

Saturday, March 6th, 2010

I think the ratings system is somewhat flawed. At least from the standpoint of being able to rate an application when you delete it from your iPhone, iPod touch, or iPad. Sure, when you have thousands of downloads, like Wooly Wind Chill has, you will have some detractors. You can’t please everyone, nor should you try. But…when a person is deleting your application from their devices, and that is when they are given the opportunity to rate the app, well, what are the chances that they are going to rate it five stars!?! If they “Loved It”, then they probably wouldn’t be deleting it.

I just think it is the equivalent of a loaded question…”ah, you are deleting me…did you not like me?”. Or, when you read on forums how awful xyz product is as posted by 10 customers (you see it all the time on Apple’s discussion forums), and yet the other 100 million users have never had a lick of an issue, which you don’t see posted as often or with as much vigor (besides, they would be labeled as “fanboys”).

Which, I guess is what I doing here….writing a blog entry because I’ve got a bit of a rant.