Internet Strategy Guide

‘UIViewControllerHierarchyInconsistency’, reason: ‘A view can only be associated with at most one view controller at a time!

by on Jul.23, 2013, under development, iOS, iPhone

So I was working on an iOS app for a client and received this error when trying to launch the app in iOS simulator. I was assured that the repository I was pulling from was the same codebase as the app currently in the store. After googling, I found several stackoverflow questions on this with a lot of text answers and 1 with a very short explanation with a before and after screenshot that didn’t explain much. As you can tell by the blog URL, iOS is currently not my programming strength, so I decided to make a blog post to go slightly deeper into this and compile the bits I learned from debugging this.

First of all, the reason I encountered was due to a change introduced in iOS 6. I forget what it was exactly but that’s why we’re seeing this error message.  What error message? Something that looks like this:

2013-07-12 11:07:52.775 App[3545:c07] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View <UIScrollView: 0x89780c0; frame = (0 20; 320 548); autoresize = W+H; gestureRecognizers = <NSArray: 0x8979730>; layer = <CALayer: 0x89782c0>; contentOffset: {0, 0}> is associated with <UIViewController: 0x8979cc0>. Clear this association before associating this view with <RootViewController: 0x753ed50>.'
*** First throw call stack:
(0x172b012 0x1110e7e 0x172adeb 0x481cb9 0x518f7c 0x515440 0x845be 0x840e7 0xaeb58 0x651019 0x1124663 0x172645a 0x64fb1c 0x5147e7 0x514dc8 0x514ff8 0x515232 0x5154da 0x52c8e5 0x52c9cb 0x52cc76 0x52cd71 0x52d89b 0x52edc6 0x52f065 0x52f1a8 0x52f5b9 0x52f257 0x52f1de 0x11bfd 0x15c589 0x15a652 0x15b89a 0x15a60d 0x15a785 0xa7a68 0x1a38911 0x1a37bb3 0x1a75cda 0x16cd8fd 0x1a7635c 0x1a762d5 0x1960250 0x16aef3f 0x16ae96f 0x16d1734 0x16d0f44 0x16d0e1b 0x20657e3 0x2065668 0x433ffc 0x1fdd 0x1f15)
libc++abi.dylib: terminate called throwing an exception

So we, obviously, have the title of this article:

'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time!

followed by the important part:

<UIScrollView: 0x89780c0; frame = (0 20; 320 548); autoresize = W+H; gestureRecognizers = <NSArray: 0x8979730>; layer = <CALayer: 0x89782c0>; contentOffset: {0, 0}> is associated with <UIViewController: 0x8979cc0>. Clear this association before associating this view with <RootViewController: 0x753ed50>.'

This is telling us a few things:

  1. The main issue is in RootViewController
  2. UIScrollView and UIViewController are in some sort of Highland/ThunderDome situation

    Highlander: The Game

    Highlander: The Game (Photo credit: Wikipedia)

So we should open up the problem file:

full view

Hey! Look, there’s the ViewController and something called Scroll View. We’re probably on the right track. It’s right there, under Objects. Let’s take a closer look at that.








 So what iOS 6 is complaining about is we have a view within a view in our view controller (kinda like Inception).
So what do we have to do to solve this? Let’s take the Scroll View child and make it a sibling.
Well now that View Controller is kinda useless, let’s clean that up.
Oh yeah, I read something about the File’s Owner Class, so let’s change that too. I’m putting a pic in of this because it’s a change I made and I’m not sure if it actually has anything to do with this but figure I’d rather have too many steps than not enough steps.

file owner classThere you have it. That’s my how I solved this issue. Hope it works for you. Hopefully someday, I can come back to this and give a more thorough explanation but for now, this is all I got.

Enhanced by Zemanta
Leave a Comment :, , , more...

PHPStorm File Templates Includes Custom Variables

by on Feb.10, 2012, under development, php, phpstorm, tools

PHPStorm’s File template settings are very versatile. They allow you to not only make a file template, but also allow you to parse out redundant elements (such as licensing) in the template by allowing an includes section. In your File Template, any undefined variable automatically elicits a prompt from PHPStorm.

PHPStorm allows you access to the includes section via the #parse directive. If you’re want To have Custom variables to be filled in correctly via prompt, you will need to have the variable declared in the template.


“chance license.php”

* @package ${Package}
* @author Chance Garcia
* @copyright (C)Copyright ${YEAR}

In the above includes example, I’m wanting to have a custom variable named Package. I can only cause PHPStorm to prompt for this value if I include the variable in my template. If I’m already using the variable in the template, then it will fill in when the includes file is parsed.


#parse("chance license.php")

class ${Package}_#if(${ExtraClassInfo} != "")${ExtraClassInfo}_#end${NAME}


In the above template, the ${Package} variable will be given a prompt since it is used in the template and an unknown variable and the parsed “chance license.php” include will be able to use that prompt value.

I am also using another variable to Prompt for extra class name information. Since PHPStorm uses Velocity Template Language (VTL), I am able to use the VTL conditional syntax to insert that information if it is entered and ignore it if it is not. This technique is useful in a situation where you want your include file to have a custom variable value but do not need to display this value in your template.


<?xml version="1.0"?>
#parse("chance license.php")


In the above example, we make PHPStorm prompt for the custom value needed for out parsed include file. This gives us our expected include file without printing our custom variable anywhere else in our template.


Update: I made a github repo ( of my templates for better examples and in case I lose my settings.

Enhanced by Zemanta
1 Comment more...

MAMP PRO, PECL, SSH2, and OSX CLI (AKA acronym madness)

by on Nov.08, 2011, under development, php, tutorial

Or madness in general. So as you may know, I’ve started using PHPStorm to work locally. I decided to dust off an old SSH2 wrapper I wrote and play with how PHPStorm uses PHPUnit and does refactoring. I knew that I would have to install the extension via PECL and was like, “Oh it can’t be that bad to do it through MAMP PRO” and as you may have guessed, I sealed my own fate for a couple hours. One thing I can say is that, even though I use a convenient app like MAMP PRO to set up my local development environment, I’m glad my sysadmin-fu is up to snuff enough to fly without the conveniences because after this ordeal, I feel like I might as well have made my MAMP stack from scratch with all the hoops I jumped tonight. (I’m pretty sure that last sentence is also one of the worst run-on sentences ever).

The first thing you need to know is that the PECL command is located at the directory


when I tried to run

sudo ./pecl install -a ssh2 channel://

from that directory, I got the error:

Notice: unserialize(): Error at offset 267 of 1133 bytes in Config.php on line 1050
PHP Notice: unserialize(): Error at offset 267 of 1133 bytes in /Applications/MAMP/bin/php/php5.3.6/lib/php/PEAR/Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.

I found out later that the error is most likely caused by the file


So if you get an error, try doing

sudo mv /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf.bkp

If you’re still getting the error, you can also the following:

  1. Install Xcode Tools from your Mac OS X DVD or download it from Apple Developer Connection
  2. Download the complete PHP source code from into /Applications/MAMP/bin/php/php5.3.6/
  3. Create an include directory in the the php5.3.6 directory.
  4. Unzip/tar the php source archive and move it to/Applications/MAMP/bin/php/php5.3.6/include/
  5. Rename the php source directory to just php (so then it will look like /Applications/MAMP/bin/php/php5.3.6/include/php)
  6. In Terminal use the following commands to compile the extension:
    cd /Applications/MAMP/bin/php/php5.3.6/include/php

That should allow you to run the PECL command however, you will probably get a complaint about not having libssh installed. So you will have to

  1. go download libssh2 ( As much as I like git, I recommend  downloading the latest release tarball instead of cloning the repo. For some reason, I got a version incompatibility error when trying to run the PECL install with the repo version and had to do all these steps over with the tarball release version.
  2. unzip the directory and cd to the upacked directory in the terminal.
  3. run: ./configure; make all install;
    libssh should compile and place the output file in src/*.o
  4. copy all headers from the include folder within the libssh2 directory to
  5. copy all compiled files (*.o) from the src folder within the libssh2
    directory to /usr/local/lib/

After you’ve successfully ran the the PECL install, it should tell you to  Add the line

to the Dynamic Extensions area of your php.ini file. I believe both MAMP and MAMP PRO allow you to edit the necessary ini through File>Edit Template.

MAMP edit php.ini


Lastly, restart apache. You should be able to see the SSH2 extension when you load a phpinfo() page.

Bonus round:

I’m not sure how I have  PHP CLI working in OSX but if you’ve followed the steps above and try to verify the extension install with through the cli, it won’t show up.

$ php -a
php> phpinfo();

This is because (if you’re also using MAMP PRO) the binaries are different. The good news is that you can make things happy in 3 easy steps

  1. run `sudo ln -s /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/ /usr/lib/php/extensions/no-debug-non-zts-20090626/` in the terminal.
  2.  Edit the /etc/php.ini (copy /etc/php.ini.default if /etc/php.ini doesn’t exist)  like you did for the MAMP php.ini(s)
  3. profit.

Note: I still have to install PHPUnit into my current setup so that may or may not elicit another blog post.


Enhanced by Zemanta
2 Comments more...

Magento Extension GitIgnore Stub

by on Oct.24, 2011, under development, Magento, php

As you may or may not know, I’ve been working with Magento lately. In the past few months, one thing I’ve found that I needed is a stock .gitignore file for when making extensions. Haven’t found one so I made one on github and will also post here for anyone else in need. I’m still relatively new at working with Magento and in someways git/github so please feel free to critique/streamline.

# replace {company} and {extension} placeholders with your information

# ignore phpstorm files

# Ignore all not in app & skin

# ignore all in js, except module files for this module

# Ignore all in app, except code & etc
# Ignore all in app/code except /local/{company}

# Ignore all in app/code/local except {company}
# use lines below if you have multiple company extensions
# and want to just commit a specific one

# Ignore all of app/etc except our specific module files

#Ignore all of app/design except for our files

Enhanced by Zemanta
1 Comment more...

Using MySQL Workbench with MAMP

by on Oct.07, 2011, under development, mysql, php, regex

Recently I’ve started working locally due to the PHPStorm IDE. In order to work locally, I invested in MAMP Pro to make use of their GUI interface for configuring vhosts. I also like to use MySQL Workbench for my database work, unfortunately these 2 items never seemed to work together for me before. After a brief google search I was able to find out how to connect to MAMP’s MySQL install to do SQL Development, which is by done by choosing the local socket connection method and using the value /Applications/MAMP/tmp/mysql/mysql.sock for the connection.

MySQL Workbench MAMP Socket Connection Settings
MySQL Workbench MAMP Connection Settings

After setting that up, I got to thinking, “I’m already using an IDE for code convenience and a GUI for vhost convenience, I should set up Server Administration with MySQL Workbench too!” So after some googling, I found an article to help me set up Server Administration with MAMP. Unfortunately the article only got things partially working and has no way to comment on it to have it corrected. So I’m going to outline the steps. Also I just noticed that the images with the article are updated correctly but it’s hard to cut and paste an image of something someone has done so I’ll just give you the value pairs

  • Configuration File: /Applications/MAMP/tmp/mysql/my.cnf
  • Start: /Applications/MAMP/bin/ -
  • Stop: /Applications/MAMP/bin/ -
  • Check MySQL Status: ps -xa | grep “/Applications/MAMP/Library/bin/[m]ysqld”
If the check status doesn’t work, just do a
ps -xa | grep MAMP
and find the correct path to mysqld
And that’s all you need to know.
MySQL Workbench MAMP System Profile Settings Tab
Enhanced by Zemanta
3 Comments more...

expected exceptions annotations, mocked object calls, oh my.

by on Dec.24, 2010, under development, php, phpunit, unittesting

Note: I have tested this in PHPUnit 3.4.1 and haven’t tried it out in 3.5.
Anyone who has worked with PHPUnit has most likely worked with expected exceptions and mock objects. The nice thing about working with expected exceptions is that we have access to a handy @expectedException annotation. I’ve gotten into the habit of using this for exceptions my fixtures should throw but also for when I’m using a mock object to verify a method call. So my tests usually expect foo_exception for fixture throws and when i’m testing method calls via a mock, they expect Exception. Therein lies my problem. Because all my custom class exceptions obviously extend the Exception class, I can get some false positives in testing.

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
class tmpTest extends PHPUnit_Framework_Testcase

     * @expectedException Exception
    public function testFooBar()
        $foo=new foo();

     * @expectedException Exception
    public function testBarBaz()
         ->will($this->throwException(new Exception('baz')));
class foo_exception extends Exception{}

class foo
    public function bar()
        throw new foo_exception('bar');

    public function baz()
        echo "bwah\n";

    public function barbaz()

So here we have an expectation for Exception but if we look at the code, we see that the bar method throws a foo_exception and the testBarBaz test is trying to test for the baz call via a mock that throws an Exception. if we change the annotation to expect foo_exception, the test still passes. This leads me to believe the best way to isolate the behavior we wish to test is to not use annotation for these sorts of tests. Or if you want to use annotation, be sure to use a unique exception for the mock. This means, unfortunately for me, that I’ll have to go back through all my tests and ensure there’s no false positives.

Lesson learned: be careful using shortcuts (and don’t stand in the fire).

On a side note, this part of PHPUnit is why those tests will behave that way. The behavior is completely my fault but I wanted to confirm it was behaving because of how it was verifying the expected exception.

Enhanced by Zemanta
5 Comments :, , , , more...

fun with arrays and requirement chains

by on Dec.01, 2010, under development, php, web dev

Recently, I had to figure out if a given set of features contained all of their necessary requirements.

For better or worse, the table was modeled so that the feature table referenced itself so that it could create a parent/child requirement chain. For example:

feature_id requirement_id
2 null
5 2
7 null
11 5

So my problem is to find out if a given set of requested features, make sure that the requirements are also present. This includes any requirements the requirement feature may have. In this example, 11 requires 5 which requires 2.
Let’s take $featureRequest1=array(2,5,7,11) and $featureRequest2=array(7,5,11). If I were to run a look up of requirements, I would find that we have


I tried to use the php in_array function but it didn’t work as I expected it to.

in_array($requirements,$featureRequest1); // i expect true
var_dump(in_array($requirements,$featureRequest1)); // false
in_array($requirements,$featureRequest2); // i expect false
var_dump(in_array($requirements,$featureRequest2)); // false

I then realized what I need is for there to be a clear intersection between the requirements and the request.

$requirements==array_intersect($requirements,$featureRequest1); // expect true
var_dump($requirements==array_intersect($requirements,$featureRequest1)); // true
$requirements==array_intersect($requirements,$featureRequest2); // expect false
var_dump($requirements==array_intersect($requirements,$featureRequest2)); // false

I should probably note that array_interest will preserve the array keys. To fix it, you can either flip the 2 arguments or pass the return array to array_values

2 Comments :, more...

Meet the PHP Dev Derby Team

by on Sep.10, 2010, under dev derby, development, php, the combine

I liked how the Dev Derby website did team leader profiles and decided to try to do something similar. No one provided any pictures but most did answer some questions I asked so without much further ado, meet the PHP Dev Derby Team.

The team consists of

  • Dennis Rogers (@_drogers)
  • Max Beatty (@maxbeatty)
  • Matthew Haralovich (aka zon)
  • Grant Simpson (@grantls)
  • Ryan Dagey (@dageytech)

Update: added in Ryan Dagey’s answers. And photo.

(continue reading…)

Leave a Comment :, more...

Call to Arms

by on Aug.20, 2010, under dev derby, php, the combine

A selection of programming language textbooks ...
Image via Wikipedia

How much code can you generate in a day?

We are actively recruiting participants to take place in a developer event (“Dev Derby“) that pits one language against others. It is a day-long programming challenge where teams of developers work to create an application serving a real-world need. Five teams will represent different programming languages—PHP, C#, Ruby, ColdFusion, and Java—to produce a demo application that will be released as open source software.

Team Leaders for each language will review applications and select competitively balanced squads. There is no cost to enter, but spots on teams are limited. Winning teams can win prizes and all participants are eligible for discounts to other tech events taking place that week.

The Dev Derby will start and end on Saturday, September 11, 2010, in Bloomington, Indiana. It is part of The Combine (, the area’s first major technology conference, and at the start of the BFusion/BFlex conference ( Dev Derby involves an intense six-hour coding session.

Each challenge submission will be judged by knowledge leaders and representatives of the non-profit organizations benefiting from this work. The criteria spans Design (features and UI choices made), Technical Efficiency (code and performance), Communication (documentation and presentation), and Practical Value (use, adoption, and maintenance).

Prizes will be awarded at the end of the day, following a panel discussion about the development process and the future of application programming.

Dev Derby is situated in The Combine along with other technology-related events, such as Tech Cocktail, Ignite Bloomington, and a variety of of other gatherings. It is hosted by the BFusion/BFlex conference, a two-day hands-on training event from the experts of Adobe Flex and ColdFusion. Dev Derby is inspired by our experience with Startup Weekend in 2008, but with a short day of coding and focused on a specific challenge.

Apply now:

Enhanced by Zemanta
1 Comment :, , , , , , , , , , more...

Valuable Professional Reading

by on Aug.11, 2010, under dev derby, development, php, the combine, zend

book cover
Image via Wikipedia

The team leaders for Dev Derby have been asked to list what we consider valuable professional reading. Our book selections are not limited to our respective Languages. I thought I would share my list with everyone.

The first 2 (GoF design patterns and Patterns of enterprise application architecture) really just need to be in every developer’s library. The rest are a collections of books I’ve read and liked as well as recommendations from developers I like and respect. Keith Casey pointed me in the general direction of a lot of these books.I suspect that some of the Dev Derby people will end up contacting various publishers to solicit swag sometime soon.

In other news about Dev Derby, I think that an application for teams should be available to announce sometime soon. I do know we have a deadline for selection approaching and it’s kinda hard to select without people to select from.

GoF design patterns:
* ISBN-10: 0201633612
* ISBN-13: 978-020163361

Patterns of enterprise application architecture:
* ISBN-10: 0321127420
* ISBN-13: 978-0321127426
(continue reading…)

1 Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!