- adjusted to support non-arc and iOS6