Recurse up entity hierarchy if no primaryAttribute found

Signed-off-by: Alexsander Akers <a2@pandamonia.us>
Fix iOS 6 deprecation warnings

Signed-off-by: Alexsander Akers <a2@pandamonia.us>