Posts tagged ‘iPhone SDK’

Stir Trek: Avengers Edition app available

My 2012 Stir Trek app has made it through the review process and is available in the App Store. It is a free app and runs on iOS 4.3 or newer devices. Here is the link to the app:

Stir Trek 2012 (app link redacted, no longer available in the app store)

OK, it is basically the same app as last year and does not use the iPad natively. But download and enjoy it anyway. And hopefully rate it 5 stars with glowing reviews.

BTW, a sad day today, Jim Marshall of Marshall Amplification has passed away at the age of 88. Which means that he made it to eleven 8 times. Turn it up loud in honor of Jim.

UI Automation – Testing From The Top Down (CIDUG meeting, March 27, 2012)

Jonathan Penn gave a presentation last night on using the UIAutomation classes in iOS and Instruments to do user interface testing of iOS apps. It was a very thorough presentation with lots of demos, which are always good. At my previous company, we tried to use UIAutomation to help out with entering of lots of data, but were stymied by something that sure looked like a bug in UIAutomation. Here was the Stack Overflow question I asked regarding this issue: (I accepted an answer that was not truly an answer because I wanted to get my accept rate back up to 100%)

iPhone UIAutomation button tap does not fire

I would love to get back into using UIAutomation, but it can take a long time to get it to do what you need it to do, and unfortunately I do not have the time I would like to spend on it.

By the way, if you have need of a mobile solution for your sales or work force, then please check out Routzy, an iPad only app that my current company just released last week. Here is a link to the product web site:

Routzy

And here is a link to the press release:

Coalesce Launches Routzy, iPad App Designed for Sales Professionals

Application failed codesign verification (!?!**!)

After rearranging the components of an iOS project around, all of a sudden the archive was giving a warning at the end:

Application failed codesign verification. The signature was invalid, contains disallowed entitlements or it was not signed with an iPhone distribution certificate. (-19011)

The strange thing is that if I went to the Verification button in the Organizer, everything was happy and the app passed initial validation.

But I figured I had best clear the warning anyway. As a result, my moving items around caused a path to become too long. The way that I fixed it was to go into the Behaviors in Xcode, Locations tab, and set the Derived Data path to a custom path that was much shorter than the normal library path that shows up there. Doing this and rebuilding caused the archive to go through normally.

The key to this was looking at this Apple web page and noticing that I was getting the “Failed to load provisioning profile from” message in my build output:

Technical Note TN2250

BTW, Happy Birthday to Billy Sheehan, one of the most talented and versatile performers that I have ever seen.

Custom UISearchBar as a header view of UITableView in IB

If you add a UISearchBar to your UITableView in Interface Builder, it gives you a nice way to put the search bar as the header view of your table view, without any extra work involved such as creating the search bar in code and setting it up as a header view of the table. (OK, it is true that this is not that much more work, but I am super lazy.)

This works great if you want to use the search bar as is, without being able to customize it at all, which includes resizing it and adding additional controls to it.

My current needs dictated that I needed to add a bar code button to the right of the search bar that the user can use to scan in a bar code and kick off a search for the encoded data. I was going for the look of the search bar that is in the eBay iPhone app.

After many tries at subclassing UISearchBar and overriding drawRect and layoutSubviews in every perverted way possible, I stumbled on this Stack Overflow question and solution:

Changing the size of the UISearchBar TextField?

Basically, what you do here is to add a UIView to the table view instead of a UISearchBar. Then, you add a UINavigationBar to the UIView, and then resize it so that it only takes up a small portion of the view. After this, then you would add a UISearchBar to the empty space in your UIView, and then adjust the size of the UISearchBar to just fill up that empty space. (The navigation bar keeps the color gradient consistent across the header view.) And finally, you can then add any controls you want to the space that the small navigation bar occupies.

The only problem with this is that you have to manually manipulate the position of the new controls, as if you try to drag and drop, you might add the control as a UINavigationItem in the UINavigationBar.

On a conference note, I got tickets for myself and my co-workers to Stir Trek (The Avengers Edition) today a few minutes after they went on sale. Which is a good thing, as I understand they sold out in less than 15 minutes. I attended last year and had a good time, and I am hoping that this year’s edition has a better movie than last year’s Thor Edition. (Unfortunately, Thor does appear in The Avengers.)

BTW, happy Pi day everyone!

It’s “ordinal date”, actually…

I’m storing birthdays in Core Data, and now I want to get a list of entities sorted by the day of their birth. However, I just cannot sort by the date, since the year of their birth would take precedence, I just need to sort by the month and day of the NSDate stored as the birth date.

The big problem that I faced was trying to find out how to get the Julian date from an NSDate. Well as it turns out, Julian date does not correctly describe what I was looking for, I needed to look for ordinal date.

After a bit of investigation, I was able to put together this category that I have hung off of NSDate in my app:

- (int)ordinalDate
{
    return [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit 
             inUnit:NSYearCalendarUnit forDate:self];
}

This, along with a sortUsingComparator of my NSMutableArray of contacts, is exactly what the doctor ordered.

BTW, Happy Birthday to the Grand Canyon National Monument, created this day in 1908, which eventually became the Grand Canyon National Park. (Yet another must see place.)

Renaming a Core Data attribute when creating a new model version

I found this one out the hard way.

If you are doing simple attribute additions when you transition from one Core Data model version to another, you can just create a new model version, set your overall data model’s default to the new version, and add the needed attributes to the entities as you need. When you fire up the app, the new fields are magically added to the table without any additional work.

However, when you want to rename an attribute, if you follow the above series of steps, the data that exists in the fields corresponding to the old attribute name is now replaced with a shiny new nil. Outstanding!

I guess I didn’t read the Apple Core Data docs well enough. Make sure that, when you add your model version and rename the attribute, make sure that you can see the Utilities view on the right side of the Xcode 4 window, click on the attribute you are renaming, click on the Data Model inspector (the third icon in the Utilities view, looks like a little database cylinder with an eye patch on it), and for the Renaming ID entry, type in the old name of the attribute. Once you do this, the data in the field should migrate forward.

Luckily, I didn’t blow away too many beta user’s data discovering this one.

BTW, a posthumous Happy Birthday to James Bond, the ornithologist whose book Ian Fleming had on his bookshelf and reportedly named his super spy character after.

UIButtonTypeInfoLight masquerading as a UIBarButtonItem

Just in case you were wondering how to use a UIButtonTypeInfoLight (or UIButtonTypeInfoDark) as a UINavigationItem (a la UIBarButtonItem), here is what I threw together. Put this code in your view controller’s viewDidLoad method:

UIButton *button1 = [UIButton buttonWithType:UIButtonTypeInfoLight];
button1.frame = CGRectMake(0.0f, 0.0f, 40.0f, 32.0f);
[button1 addTarget:self action:@selector(aboutButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *aboutButton = [[UIBarButtonItem alloc] initWithCustomView:button1];
self.navigationItem.leftBarButtonItem = aboutButton;
[aboutButton release];

Adjust the frame to your taste, and supply the aboutButtonPressed method with an (id)sender parameter, and you are good to go.

Open Source iOS Projects (CIDUG meeting, November 22, 2011)

Thanks to everyone who turned out on Tuesday night for my CIDUG presentation on utilizing open source iOS projects. The presentation went a bit longer than I was hoping, largely due to the volume of demos that I had.

If you would like to download a PDF of the presentation, here is a link:

Open Source iOS Projects presentation

Also, if you would like to download a ZIP file of all of the demos that I did, here is a link for that:

Open Source iOS Projects demos

I realized this morning that what I should have done was to create a workspace, and then drag all of the individual projects into that one workspace for the demo. I have done this in the code that I uploaded, so when you unzip the demos file, just open the Demo projects.workspace file and then just use the Scheme selector at the top of the Xcode window to select which demo you want to look at or try out.

Please let me know if you have any questions or suggestions on the presentation or the demo code. I hope everyone out there has a safe and happy holiday season.

Details

It has been a while since I have made a post, so I figured I would take this opportunity to point out that, if you are ever putting together a UITableViewCell (such as in the cellForRowAtIndexPath delegate method), there is a big difference between this:

cell.backgroundColor = [UIColor redColor];

And this:

cell.contentView.backgroundColor = [UIColor redColor];

Or, if you are creating an NSSortDescriptor, there is a big difference between this:

sortDesc = [[NSSortDescriptor alloc] initWithKey:@"sortOrder" ascending:YES];

And this:

sortDesc = [[NSSortDescriptor alloc] initWithKey:@"sortOrder" ascending:YES
                selector:@selector(localizedCaseInsensitiveCompare:)];

Happy Nigel Tufnel day and Last Binary Day Of This Century (11/11/11) to everyone!

Paradise lost?

A couple of years ago, I wrote a blog post about displaying and dismissing a view controller in an iPhone application. To get rid of your view controller from within that view controller, you would simply run this line of code:

[[self parentViewController] dismissModalViewControllerAnimated:YES];

Alas, with the update to iOS SDK version 5, this no longer works. And in fact, if you spelunk through the UIViewController.h file, it does say that as of 5.0, it will no longer return the presenting view controller.

Luckily, you can just do this instead:

[self dismissModalViewControllerAnimated:YES];

BTW, happy birthday to Roger Moore, star of the excellent films “The Cannonball Run” and “ffolkes”.