Replace NSAssert to throw NSException.