steipete/PSTCollectionView — pull request #402 by ryanstew (2014-08-14 22:38:56+00:00)
Title: Handle the larger UICollectionView in iOS 8

This addresses a `UICollectionView` size mismatch that prevents `PSUICollectionView `from having its superclass overwritten on iOS 8, and changes the `PSTRegisterClass(...)` behavior to prevent a mix of `UICollectionView` and `PSTCollectionView` superclasses for `PSUICollectionView_` types.

On iOS 8 (beta 5) on-device, we've noticed that `UICollectionView` is 32 bytes larger than its `PSTCollectionView` counter-part, causing `PSTRegisterClass(...)` to fail for that pair. All other types have their superclass overwritten.

When this happens, `PSUICollectionView` is a `PSTCollectionView`, but `PSUICollectionViewLayout` and its subtypes are `UICollectionViewLayout`s. An example implication of this is demonstrated by something like the following:

```objective-c
PSUICollectionViewFlowLayout *layout = [[PSUICollectionViewFlowLayout alloc] init];
//
PSUICollectionView *collectionView = [[PSUICollectionView alloc] initWithFrame:bounds collectionViewLayout:layout];
```

In the case where `PUICollectionView` is a `PSTCollectionView`, its `initWithFrame:collectionViewLayout:` assumes the layout is a `PSTCollectionViewLayout`. Since `PSUICollectionViewFlowLayout` is a `UICollectionViewFlowLayout`, this ends up failing in `setCollectionViewLayout:animated:` during the init call, which attempts to set the read-only property `collectionView` on the layout. This is only writable on `PSTCollectionViewLayout`, not `UICollectionViewLayout`.

I assume similar assumptions exist elsewhere in the code, and the use of `PSUI` types as above is expected to be safe.

So in addition to the basic addition of additional padding for ivars in `PSTCollectionView`, I'm trying to be a bit more defensive about these sorts of object size changes in the future. So, I'm proposing this two-pass registration process of the `PSUI*` types, which will validate that all types *can* be changed before allowing any of them to be changed. This should prevent the case of partial conversion, and fall back to the all-`PST` state if another size mismatch is introduced by a future iOS update.