How to Know When Apple Finally Gets iCloud Right [#iosdev #icloud]

Gus Mueller of Flying Meat Software offers his opinions on what Apple must do to get iCloud right for developers:

The Shape of Everything: How to Know When Apple Finally Gets iCloud Right

But how are we going to know Apple has finally fixed iCloud syncing for developers and is really serious this time? And I’m not just talking about Core Data syncing, I’m also talking about the APIs developers are given to push document data back and forth. The broken stuff, the things developers laugh at Apple about and have given up on.

Super-Easy Date Formatting in Objective-C [#iosdev]

Available since iOS 4, the localizedStringFromDate:dateStyle:timeStyleclass method provides an extremely convenient way of formatting a date as a string. All you have to do is provide your NSDate object that you wish to convert, and pass the appropriate NSDateFormatterStyle value for the types of formats you would like for your date and time parts of the date. If you use NSDateFormatterNoStyle then the particular part will not be rendered. The other good news is that it’s generating a localized string, so the format is taken care of by the framework, which, honestly, is exactly how it should work in the first place.
Example:
[NSDateFormatter localizedStringFromDate:myDate
dateStyle:NSDateFormatterShortStyle 
timeStyle:NSDateFormatterNoStyle];
The generates “3/22/13″ in my locale (US), but if I switch my device to Portugal, for instance (of course), the date becomes “21/03/13″.
Here’s a link to the Apple Developer Docs.

How to conceal UIWebView’s initial white loading view [#iosdev]

Thanks to this StackOverflow thread, I was able to conceal UIWebView’s intial white, “blank page” look while it was loading.

iphone uiwebview inital white view – Stack Overflow

One thing you can try is put a UIView with the color you want and position it above the UIWebView with the same width and height. Then in the webViewDidFinishLoad method, set the UIView to hidden.

Hope it proves useful to someone else.

-e

Iterating through NSDictionary [#iosdev]

This was very helpful to me recently…

Iterating through NSDictionary

Iteration through NSDictionary could be achieved at least in two ways: using NSArray with [NSDictionary allKeys] or NSEnumerator.

Method 1:

NSArray *keyArray =  [bigUglyDictionary allKeys];
int count = [keyArray count];
for (int i=0; i < count; i++) {
  NSDictionary *tmp = [bigUglyDictionary objectForKey:[ keyArray objectAtIndex:i]];
}

Method 2:

NSEnumerator *enumerator = [bigUglyDictionary keyEnumerator];
id key;
while ((key = [enumerator nextObject])) {
  NSDictionary *tmp = [bigUglyDictionary objectForKey:key];
}

Second way is a little bit faster, so if you work with huge dictionaries and have no need of array with their keys – use it.

 

Hope it helps someone else too!

Tip: Generate a File List in TextWrangler [#devtips]

Here’s a really easy way to generate a list of files using TextWrangler:

  1. Open a new window in TextWrangler.
  2. Navigate to the folder you want in Finder.
  3. Drag that folder from the Finder window to the TextWrangler window.
  4. TextWrangler generates a cleanly-formatted listing of all the contents of that folder, including all sub-folders and their contents.

I would imagine this would work in BBEdit as well, but I have not tested it.

Source: See Post #17 here: Mac Rumors – How to print a list of files in a folder 

[self shoot:foot]; (#iosdev #xcode, #ios6)

If you need to stay with Xcode 4.3 and you’re not ready to make the 4.5 jump, be very careful when upgrading your devices to iOS 6 (i.e. consider not doing it).

Yesterday, I upgraded my iPhone 4 to iOS 6 and now my current version of Xcode (4.3.3) cannot deploy to it. 

I completely forgot that Xcode has this limitation. It’s similar to a situation that I encountered a while back when I upgraded my devices to iOS 5, but that was worse because at that time I couldn’t upgrade to Xcode 4.3 because my MacBook Pro had a Core Duo processor and could not be upgraded to Lion (Xcode 4.3 required Lion). Unfortunately, the development team I’m working with is sticking with Xcode 4.3 for the time being so that means my iPhone can’t be used for testing now.

This is really annoying.

The good news is that I have an iPad that is on iOS 5.1, and it can’t be upgraded. The bad news is that we’re working on a product for iPhone. The experience feels a bit different when using it on iPad, but I’ll just have to use the simulator most of the time and then the iPad when I need to do on-device testing.
Be careful out there.

Git Tip: How to Delete a Remote Branch

This is one of the many git functions I always have to look up, and it always makes me insane at its non-intuitiveness. However, as it is a necessary evil, I thought it useful to capture it here.

Believe it or not, you have to use git push to delete. You heard that right. Stop gawking. Jaw closed.

OK so here’s how you do it:

git push origin :[name of branch]

As a concrete, though perhaps not entirely realistic example:

git push origin :my-awesome-feature

Thanks to the following blogs for their constant assistance in helping me remember (or not remember) this function:

git ready : push and delete remote branches
Yuji Tomita : Git — Delete Remote Branch

Thanks guys!

Posted in Git