Author Archives: Yonat Sharon

Simple UIProgressHUD replacement

The private API UIProgressHUD shows an activity indicator (spinner) over a shaded round rect. Although you can use fancy and flexible replacements like MBProgressHUD, there is a simpler way if you don’t need all the extra functionality: Take a regular … Continue reading

Posted in Uncategorized | Leave a comment

The Three Underscores Idiom

This is something I learned on my first programming job (eons ago…) and found useful but underused. Useful for what? To solve the persistent tension between the robustness of single-exit point and the complexity of using extra state variables and … Continue reading

Posted in Uncategorized | Tagged , , | 1 Comment

Dynamic UIActionSheet

Some actions may sometimes have more than one possible target, and other times only one. For example: Calling a contact. If the contact has just one phone number, you openURL with it and you’re done. But if she has several … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Reordering a UITableView

I like the simple and straightforward interface of the Reminders.app: edit reminders inline, and add a reminder by tapping and typing in the next empty line. So I wrote a UITableViewController subclass that does just that, but adds Edit mode … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

How to Keep Your Protocols Private

Don’t you just hate when a small change in the innards of your view controller forces you to change its header file just to conform to a delegate protocol? For example, adding emailing functionality requires you to implement the MFMailComposeViewControllerDelegate … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

BadgeLabel – Simple UILabel-based Badge

I know, I know – not another badge class! But the thing is, the other badges laying around the net all seem overly complicated and too inflexible. So yes, I wrote another badge class. Luckily, it was really easy because … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

Render UIView to UImage

There’s a simple way to render a UIView into a UIImage: use the view’s layer, and render it into a bitmap graphic context. Here is the code, phrased as a UIView category: Just remember to link the QuartzCore.framework and you’re … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

How To Make NSLocalizedString Fun To Use

To localize apps (which means: to make them work in other languages) you need to avoid using plain @”strings” and instead use the one of the tedious functions NSLocalizedString, NSLocalizedStringFromTable, or NSLocalizedStringFromTableInBundle, that take two to four arguments. Horror. I … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Store UIImage in CoreData Without Writing Any Code

There is an easy but little known way to store many kinds of UIKit objects in CoreData without writing any code. It works for UIImage, UIColor, UIBezierPath, MKPlaceMark, NSDate, and any other class that conforms to the NSCoding protocol. What … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment