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

How to delete all .svn folders in Linux / Mac [#iosdev #git #svn]

I found this useful recently when receiving a batch of code from a client who still uses Subversion…

How to delete all .svn folders in Linux / Mac? – Techie Corner

To delete all .svn folder in Linux just follow the steps below:

  • Start Terminal
  • Change your current directory to your project folder (ex: /Users/me/Sites/project_a)
  • Enter the following into Terminal: find ./ -name “.svn” | xargs rm -Rf 

That should take care of it. In my tests I found one or two that still remained but this took most of the pain out of it.

Github Tip: What to do if Github is asking for Username and Password

Recently I had a strange thing happen with a new project hosted by Github, by which every transaction with the server requried a username and password. Thankfully, this Stackoverflow post helped me resolve it.

If Github is constantly asking for your credentials when you do a clone, pull, or push, and you know you have your SSH key already in your Github profile, check to see if you set up your local repository with the HTTPS version of the repository when you cloned it instead of the SSH version. If you can remember.

In either case, do the following:

  1. Blow away (or rename safely) your current repository directory.
  2. Go to the Github page of your project.
  3. Next to the text box that contains the URL for your repository to use for cloning purposes, click “SSH” to activate it. You will see the address change from “https://…” to “git@github.com…”.
  4. Copy the new address and use that to re-clone your repository in a fresh directory.

Hope that helps.

Resend a Message in Mac OS X Mail

I’ve been using Mac OS X Mail.app for some years now and have always wanted the ability to resend an email message after I had already sent it (e.g. resend it to another recipient, instead of forwarding). I always thought this was a missing feature of Mail.

Turns out it’s not. It has been there all along in various forms, and here’s how you do it:

How to Resend a Message in Mac OS X Mail – About Email

  • Resend a Message in Mac OS X Mail To send a message again in Mac OS X Mail:
  • Highlight the message in the Sent folder (or any other folder you have moved it to).
  • Select Message | Send Again from the menu (or press Command-Shift-D).
    • In Mac OS X Mail 1.x, select File | Open As New Message from the menu.
  • Edit the message and send it (again), like a new message.
Posted in Mac